orange 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,7 @@ module Orange
45
45
  include DataMapper::Resource
46
46
  property(:id, Serial)
47
47
  self.scaffold_properties ||= []
48
- init
48
+ self.init
49
49
  end
50
50
 
51
51
  # Stub init method
@@ -2,7 +2,7 @@
2
2
  %thead
3
3
  %tr
4
4
  - for prop in props
5
- %th= prop[:name].to_s.capitalize
5
+ %th= prop[:name].to_s.split("_").each{|str| str.capitalize!}.join(" ")
6
6
  %th
7
7
  %tbody
8
8
  - for obj in list
data/lib/orange-more.rb CHANGED
@@ -15,6 +15,7 @@ require File.join(libdir, 'orange-more', 'testimonials')
15
15
  require File.join(libdir, 'orange-more', 'adverts')
16
16
  require File.join(libdir, 'orange-more', 'contactforms')
17
17
  require File.join(libdir, 'orange-more', 'analytics')
18
+ require File.join(libdir, 'orange-more', 'donations')
18
19
  require File.join(libdir, 'orange-more', 'cloud')
19
20
  require File.join(libdir, 'orange-more', 'debugger')
20
21
  require File.join(libdir, 'orange-more', 'subsites')
@@ -16,7 +16,7 @@ module Orange
16
16
  def pageviews(route, opts = {})
17
17
  return "No GA" unless gattica
18
18
  r = route.to_s
19
- # Strip of trailing slash if present. GA doesn't like it.
19
+ # Strip trailing slash if present. GA doesn't like it.
20
20
  if r.rindex('/') > 0
21
21
  r[r.rindex('/')] = ''
22
22
  end
@@ -0,0 +1 @@
1
+ require File.join('orange-more', 'donations', 'plugin')
@@ -0,0 +1,9 @@
1
+ class OrangeDonation < Orange::Carton
2
+ id
3
+ admin do
4
+ title :donor_name, :length => 255
5
+ text :donor_company, :length => 255
6
+ text :donor_email, :length => 255
7
+ text :donation_amount
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ Dir.glob(File.join(File.dirname(__FILE__), 'cartons', '*.rb')).each {|f| require f }
2
+ Dir.glob(File.join(File.dirname(__FILE__), 'resources', '*.rb')).each {|f| require f }
3
+
4
+ module Orange::Plugins
5
+ class Donations < Base
6
+ views_dir File.join(File.dirname(__FILE__), 'views')
7
+
8
+ resource Orange::DonationsResource.new
9
+ end
10
+ end
11
+
12
+ Orange.plugin(Orange::Plugins::Donations.new)
@@ -0,0 +1,51 @@
1
+ module Orange
2
+ class DonationsResource < Orange::ModelResource
3
+ use OrangeDonation
4
+ call_me :donations
5
+ def stack_init
6
+ orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Donations')
7
+ orange[:radius].define_tag "donations" do |tag|
8
+ template = tag.attr["template"] || "donate_form"
9
+ orange[:donations].form(tag.locals.packet, {:template => template})
10
+ end
11
+ end
12
+
13
+ def form(packet, opts = {})
14
+ template = opts[:template].to_sym || :donate_form
15
+ packet['route.return_path'] = packet.request.path.to_s
16
+ do_view(packet, template, opts)
17
+ end
18
+
19
+ def donate_cancel(packet, opts = {})
20
+ id = packet.session['donation_id']
21
+ m = model_class.get(id)
22
+ m.destroy!
23
+ packet.flash['error'] = "There was an issue completing the process on Paypal."
24
+ packet.reroute((packet.flash('reroute.to') || '/'))
25
+ end
26
+
27
+ def process(packet, opts = {})
28
+ params = packet.request.params
29
+ route = params.delete('r')
30
+ params['donation_amount'] = params['donation_amount'].sub(/\$/, '')
31
+ if params['donor_phone'] == '' && packet.request.post? && params['donation_amount'] != '' && params['donation_amount'].to_f >= 0
32
+ template = "paypal_form"
33
+ params.delete('donor_phone')
34
+ obj = self.new(packet, {:no_reroute => true, :params => params})
35
+ packet.session['donation_id'] = obj.id
36
+ packet.flash['reroute.to'] = route
37
+ opts[:donation_amount] = params['donation_amount']
38
+ opts[:paypal_id] = orange.options['paypal_id'] || ''
39
+ do_view(packet, template, opts)
40
+ else
41
+ packet.flash['error'] = "An error has occurred. Please try your submission again."
42
+ packet.reroute(route)
43
+ end
44
+ end
45
+
46
+ def donate_success(packet, opts = {})
47
+ template = "donate_thanks"
48
+ do_view(packet, template, opts)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ :javascript
2
+ $(function(){
3
+ $('#donate_form').validate();
4
+ });
5
+ %p
6
+ - if(flash['error'])
7
+ .error= flash('error')
8
+ %form{ :class => 'donate_form', :id => 'donate_form', :action => route_to(:donations, :process), :method => 'POST' }
9
+ %label{ :for => 'donor_name'} Your Name
10
+ %input{ :type => 'text', :minlength => '4', :maxlength => '80', :id => 'donor_name', :name => 'donor_name', :class => 'required' }
11
+ %div.donor_phone
12
+ %label{ :for => 'donor_phone'} Your Phone
13
+ %input{ :type => 'text', :minlength => '4', :maxlength => '80', :id => 'donor_phone', :name => 'donor_phone', :value => '' }
14
+ %label{ :for => 'donor_company'} Your Company
15
+ %input{ :type => 'text', :minlength => '4', :maxlength => '180', :id => 'donor_company', :name => 'donor_company', :value => '' }
16
+ %label{ :for => 'donor_email'} Your E-mail
17
+ %input{ :type => 'text', :class => 'email', :id => 'donor_email', :name => 'donor_email' }
18
+ %label{ :for => 'donation_amount'} Donation Amount: $
19
+ %input{ :type => 'text', :class => 'donation_amount', :id => 'donation_amount', :name => 'donation_amount' }
20
+ %input{ :type => 'submit', :value => 'Submit' }
21
+ %input{ :type => 'hidden', :id => 'r', :name => 'r', :value => packet['route.return_path'] }
@@ -0,0 +1,2 @@
1
+ %h3 Thank You!
2
+ %p Thanks for your donation!
@@ -0,0 +1,13 @@
1
+ %h3 Redirecting to PayPal...
2
+ %form{ :id => 'pform', :name => '_xclick', :action => 'https://www.paypal.com/cgi-bin/webscr', :method => "post" }
3
+ %input{ :type => 'hidden', :name => 'cmd', :value => "_donations" }
4
+ %input{ :type => 'hidden', :name => 'business', :value => paypal_id }
5
+ %input{ :type => 'hidden', :name => 'item_name', :value => "WNSF Donation" }
6
+ %input{ :type => 'hidden', :name => 'currency_code', :value => "USD" }
7
+ %input{ :type => 'hidden', :name => 'amount', :value => donation_amount }
8
+ %input{ :type => 'hidden', :name => 'return', :value => 'http://'+packet['route.site_url'] + route_to(:donations, :donate_success) }
9
+ %input{ :type => 'hidden', :name => 'cancel_return', :value => 'http://'+packet['route.site_url'] + route_to(:donations, :donate_cancel)}
10
+ :javascript
11
+ $(function(){
12
+ $('#pform').submit();
13
+ })
@@ -232,7 +232,7 @@ module Orange
232
232
  hash = model.attributes
233
233
  # return slug(model.title) if hash.has_key?(:title)
234
234
  # return slug(model.name) if hash.has_key?(:name)
235
- return 'page-'+model.id
235
+ return 'page-'+model.id.to_s
236
236
  end
237
237
 
238
238
  def link_text_for(route)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-03 00:00:00 -04:00
17
+ date: 2010-06-07 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -186,6 +186,13 @@ files:
186
186
  - lib/orange-more/disqus/plugin.rb
187
187
  - lib/orange-more/disqus/resources/disqus_resource.rb
188
188
  - lib/orange-more/disqus/views/disqus/comment_thread.haml
189
+ - lib/orange-more/donations.rb
190
+ - lib/orange-more/donations/cartons/donation_carton.rb
191
+ - lib/orange-more/donations/plugin.rb
192
+ - lib/orange-more/donations/resources/donations_resource.rb
193
+ - lib/orange-more/donations/views/donations/donate_form.haml
194
+ - lib/orange-more/donations/views/donations/donate_thanks.haml
195
+ - lib/orange-more/donations/views/donations/paypal_form.haml
189
196
  - lib/orange-more/events.rb
190
197
  - lib/orange-more/events/assets/js/events.js
191
198
  - lib/orange-more/events/cartons/orange_calendar.rb