Skip to content

Commit

Permalink
fix promodvd ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 4, 2012
1 parent 4307ac2 commit deb4963
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 44 deletions.
73 changes: 37 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
actionmailer (3.2.9)
actionpack (= 3.2.9)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
actionpack (3.2.9)
activemodel (= 3.2.9)
activesupport (= 3.2.9)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
sprockets (~> 2.2.1)
activemodel (3.2.9)
activesupport (= 3.2.9)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activerecord (3.2.9)
activemodel (= 3.2.9)
activesupport (= 3.2.9)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
activeresource (3.2.9)
activemodel (= 3.2.9)
activesupport (= 3.2.9)
activesupport (3.2.9)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
Expand All @@ -37,7 +37,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
delayed_job (3.0.3)
delayed_job (3.0.4)
activesupport (~> 3.0)
delayed_job_active_record (0.3.3)
activerecord (>= 2.1.0, < 4)
Expand All @@ -47,14 +47,14 @@ GEM
fssm (0.2.9)
gettext (2.3.3)
locale
gettext_i18n_rails (0.7.1)
gettext_i18n_rails (0.8.0)
fast_gettext (>= 0.4.8)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.5)
locale (2.0.8)
mail (2.4.4)
Expand All @@ -63,8 +63,8 @@ GEM
treetop (~> 1.4.8)
memcache-client (1.8.5)
mime-types (1.19)
minitest (4.2.0)
multi_json (1.3.7)
minitest (4.3.2)
multi_json (1.4.0)
mysql2 (0.3.11)
nokogiri (1.5.5)
pkg-config (1.1.4)
Expand All @@ -76,33 +76,34 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
rails (3.2.9)
actionmailer (= 3.2.9)
actionpack (= 3.2.9)
activerecord (= 3.2.9)
activeresource (= 3.2.9)
activesupport (= 3.2.9)
bundler (~> 1.0)
railties (= 3.2.8)
rails-i18n (0.7.0)
railties (= 3.2.9)
rails-i18n (0.7.1)
i18n (~> 0.5)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
railties (3.2.9)
actionpack (= 3.2.9)
activesupport (= 3.2.9)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rake (10.0.2)
rdoc (3.12)
json (~> 1.4)
sass (3.2.2)
sass (3.2.3)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
sprockets (2.2.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/order_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def new
def create
@order = Order.new params[:order]
if @order.save
Promomailer.deliver_promo_order @order
Promomailer.promo_order(@order).deliver
redirect_to "/order/thanks" and return
else
flash.now[:error] = "Your submission could not be processed, please fix the problems listed below: \n"
Expand Down
5 changes: 5 additions & 0 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ class Order < ActiveRecord::Base
validates_presence_of :title, :name, :street1, :zip, :city, :country,
:phone, :email, :amount, :reason, :deadline

attr_accessible :title, :name, :street1, :zip, :city, :country,
:phone, :email, :amount, :reason, :deadline, :company, :street2, :county, :material

validates :email, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create }
validates :deadline, format: { with: %r{^2[0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]}, on: :create }, unless: "deadline == 'NONE'"
validates_numericality_of :amount
end
7 changes: 2 additions & 5 deletions app/models/promomailer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
class Promomailer < ActionMailer::Base
def promo_order(order)
# TODO: move to config/environment.rb
recipients ["promodvds@opensuse.org"]
from order[:email]
subject "openSUSE PromoDVD order: #{order[:amount]} to #{order[:name]}"
body :order => order
@order = order
mail(to: CONFIG['order_mails_to'], from: order[:email], subject: "openSUSE PromoDVD order: #{order[:amount]} to #{order[:name]}")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ until:
Reason:
<%=@order[:reason]%>


2 changes: 2 additions & 0 deletions config/options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ api_username: test
api_password: test

#use_static: software.o.o

order_mails_to: promodvds@opensuse.org
10 changes: 9 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@
match 'appstore/:category' => :category, :constraints => { :category => /[\w\-\.: ]+/ }
end

resource :orders, :controller => "order"
resource :orders, :controller => "order" do
member do
get 'thanks'
end
end

controller 'order' do
match 'order/thanks' => :thanks
end

match 'promodvd' => "order#new"
match 'promodvds' => "order#new"
Expand Down

0 comments on commit deb4963

Please sign in to comment.