Changesets can be listed by changeset number.
The Git repository is here.
Changeset 464
Canvass version 1.0.2.
- Comitted by: rool
- Date: Saturday May 03 09:48:48 2014 (over 10 years ago)
Affected files:
- rool/rails/canvass/trunk/README.md (from rool/rails/canvass/trunk/README:461)
- rool/rails/canvass/trunk/db/schema.rb
- rool/rails/canvass/trunk/Rakefile (diff)
- rool/rails/canvass/trunk/app/controllers/donations_controller.rb (diff)
- rool/rails/canvass/trunk/app/helpers/donations_helper.rb (diff)
- rool/rails/canvass/trunk/app/models/donation.rb (diff)
- rool/rails/canvass/trunk/app/models/poll.rb (diff)
- rool/rails/canvass/trunk/app/views/donations/_list.html.erb (diff)
- rool/rails/canvass/trunk/app/views/donations/new.html.erb (diff)
- rool/rails/canvass/trunk/app/views/donations/show.html.erb (diff)
- rool/rails/canvass/trunk/config/environment.rb (diff)
- rool/rails/canvass/trunk/config/locales/en.yml (diff)
rool/rails/canvass/trunk/Rakefile:
prev. | current | |
require 'rake' | ||
require 'rake/testtask' | ||
8 | ||
8 | require 'rake/task' | |
require 'tasks/rails' |
rool/rails/canvass/trunk/app/controllers/donations_controller.rb:
prev. | current | |
def new | ||
@poll = Poll.find_by_id( params[ :poll_id ] ) | ||
@donation = Donation.generate_for( @poll, current_user, '0', '0' ) | ||
62 | params[ :payment_method ] = current_user.admin? ? 'none' : 'onsite' | |
end | ||
# POST /polls/<n>/donations | ||
def create | ||
67 | ||
68 | payment_method = params[ :payment_method ] | |
69 | ||
70 | redirect_to root_path() and return if ( | |
71 | %w{ none onsite offsite }.include?( payment_method ) == false || | |
72 | ( payment_method == 'none' && current_user.admin? == false ) | |
73 | ) | |
74 | ||
75 | # Here, we know that the payment method parameter is valid and the | |
76 | # current user has permission to use whatever method was specified. | |
77 | ||
begin | ||
79 | options = {} | |
80 | ||
81 | if ( payment_method == 'none' ) | |
82 | options[ :external ] = true | |
83 | options[ :name ] = params[ :payment_none_donor_name ] | |
84 | options[ :email ] = params[ :payment_none_donor_email ] | |
85 | end | |
86 | ||
@poll = Poll.find_by_id( params[ :poll_id ] ) | ||
@donation = Donation.generate_for( | ||
@poll, | ||
current_user, | ||
params[ :donation ][ :amount_integer ], | ||
72 | | |
92 | params[ :donation ][ :amount_fraction ], | |
93 | options | |
) | ||
95 | ||
rescue => error | ||
appctrl_report_error( error ) | ||
76 | | |
98 | redirect_to root_path() | |
99 | ||
end | ||
79 | | |
80 | | |
81 | | |
82 | | |
83 | | |
102 | saved = @donation.save | |
103 | ||
104 | if ( saved && payment_method == 'none' ) | |
105 | saved = Donation.transaction do | |
106 | @donation.notes = t( :'uk.org.pond.canvass.controllers.donations.view_external_note' ) | |
107 | @donation.invoice_number = InvoiceNumber.next! | |
108 | @donation.paid! # See Workflow state machine definitions in donation.rb | |
109 | @donation.save | |
end | ||
111 | end | |
112 | ||
113 | if saved | |
114 | redirect_to( case payment_method | |
115 | when 'onsite' | |
116 | new_poll_payment_gateway_onsite_path( @poll ) | |
117 | when 'offsite' | |
118 | new_poll_payment_gateway_offsite_path( @poll ) | |
119 | when 'none' | |
120 | poll_path( @poll ) | |
121 | end ) | |
else | ||
render :action => 'new' | ||
end |
rool/rails/canvass/trunk/app/helpers/donations_helper.rb:
prev. | current | |
def donationshelp_user_link( donation ) | ||
if ( donation.user.nil? ) | ||
h( donation.user_name ) | ||
38 | elsif ( donation.user_name != donation.user.name ) | |
39 | t( | |
40 | :'uk.org.pond.canvass.generic_messages.via', | |
41 | :one => h( donation.user_name ), | |
42 | :two => link_to( h( donation.user.name ), donation.user ) | |
43 | ).html_safe() | |
else | ||
link_to( h( donation.user_name ), donation.user ) | ||
end |
rool/rails/canvass/trunk/app/models/donation.rb:
prev. | current | |
# THE OBJECT IS NOT SAVED to allow for validations to be checked at a higher | ||
# level. THE CALLER MUST SAVE THE OBJECT unless it is temporary. | ||
# | ||
300 | | |
300 | # As a special case for administrators registering external donations, you | |
301 | # can pass override options in the last parameter for the recorded user name | |
302 | # and e-mail address. The donation is still recorded against the given User | |
303 | # in the second parameter - this should be the admin - but the name and | |
304 | # e-mail can be different (e.g. the admin fills this into a form). Set keys | |
305 | # ":external" to "true", ":name" to the human readable person's full name and | |
306 | # ":email" to the e-mail address. If nil, an empty string is stored. If you | |
307 | # fail to pass ":external => true" in the options, then the administrator's | |
308 | # in-progress initial state donations, if any, may be accidentally wiped. | |
309 | # | |
310 | def self.generate_for( poll, donor, donation_integer, donation_fraction, options = {} ) | |
302 | | |
312 | self.safely_destroy_initial_state_donations_for( donor ) unless options[ :external ] == true | |
return Donation.transaction do | ||
... | ... | |
# Create the new donation object. | ||
322 | options[ :name ] = donor.name unless options.has_key?( :name ) | |
323 | options[ :email ] = donor.email unless options.has_key?( :email ) | |
324 | ||
donation = Donation.new( | ||
:user => donor, | ||
314 | | |
315 | | |
327 | :user_name => options[ :name ] || "", | |
328 | :user_email => options[ :email ] || "", | |
:poll => poll, | ||
:poll_title => poll.title, |
rool/rails/canvass/trunk/app/models/poll.rb:
prev. | current | |
# Purpose:: Describe a bounty poll. | ||
# ---------------------------------------------------------------------- | ||
# 30-Jan-2011 (ADH): Created. | ||
8 | # 24-Oct-2013 (ADH): Added 'reverted' event. | |
######################################################################## | ||
class Poll < ActiveRecord::Base | ||
... | ... | |
# | ||
# Administrators can still choose to expire a poll if they wish, should | ||
# the developer be taking "too long" to complete the work. That's up to | ||
180 | | |
181 | # individual administrators or organisations to assess. The poll is | |
182 | # considered abandoned and money redistributed to others. | |
# | ||
# Administrators may choose to revert a poll, if it turns out it was | ||
# not really being developed or a developer halts work. The poll is |
rool/rails/canvass/trunk/app/views/donations/_list.html.erb:
prev. | current | |
-%> | ||
<div class="searchable_list" id="donations"> | ||
<% if @items.empty? -%> | ||
7 | | |
7 | <%= apphelp_view_hint( :no_index_items, DonationsController ) %> | |
<p /> | ||
<div class="buttons"> | ||
<%= apphelp_protected_button_to( :index, { :method => :polls_path, :controller => PollsController } ) %> |
rool/rails/canvass/trunk/app/views/donations/new.html.erb:
prev. | current | |
</p> | ||
<p> | ||
25 | <% if current_user.admin? -%> | |
26 | <table border="0" cellspacing="0" cellpadding="0" class="no_border abuted"> | |
27 | <tr valign="top"> | |
28 | <td> | |
29 | <%= radio_button_tag( :payment_method, :none, params[ :payment_method ] == 'none' ) -%> | |
30 | </td> | |
31 | <td> | |
32 | <%= label_tag( :payment_method_none, apphelp_view_hint( :payment_none_hint ) ) %> | |
33 | <table border="0" cellspacing="0" cellpadding="0" class="no_border abuted"> | |
34 | <tr valign="top"> | |
35 | <td align="right"> | |
36 | <small><em><%= apphelp_view_hint( :and_if_so_donor_name ) %></em></small> | |
37 | </td> | |
38 | <td><%= text_field_tag( :payment_none_donor_name ) %></td> | |
39 | </tr> | |
40 | <tr valign="top"> | |
41 | <td align="right"> | |
42 | <small><em><%= apphelp_view_hint( :and_donor_email ) %></em></small> | |
43 | </td> | |
44 | <td><%= text_field_tag( :payment_none_donor_email ) %></td> | |
45 | </tr> | |
46 | </table> | |
47 | </td> | |
48 | </tr> | |
49 | </table> | |
50 | <% end -%> | |
<% unless ( PaymentGateway.instance.gateway_is_express_only() ) -%> | ||
26 | | |
52 | <%= radio_button_tag( :payment_method, :onsite, params[ :payment_method ] == 'onsite' ) -%> | |
<%= label_tag( :payment_method_onsite, apphelp_view_hint( :payment_onsite_hint ) ) %> | ||
<% end -%> | ||
<% if ( PaymentGateway.instance.gateway_is_express_only() || PaymentGateway.instance.gateway_has_express_support() ) -%> |
rool/rails/canvass/trunk/app/views/donations/show.html.erb:
prev. | current | |
<th><%= Donation.human_attribute_name( :amount_for_sorting ) %></th> | ||
<td><%= currencyhelp_compose( @donation.currency, @donation.amount_integer, @donation.amount_fraction ) %></td> | ||
<tr> | ||
18 | <% if current_user.admin? -%> | |
19 | <tr> | |
20 | <th><%= Donation.human_attribute_name( :notes ) %></th> | |
21 | <td><%= h( @donation.notes ) %></td> | |
22 | <tr> | |
23 | <% end -%> | |
</table> | ||
<p> |
rool/rails/canvass/trunk/config/environment.rb:
prev. | current | |
config.gem 'fastercsv', :version => '>= 1.5.3' | ||
config.gem 'ya2yaml', :version => '>= 0.30' | ||
config.gem 'locale', :version => '>= 2.0.5' | ||
66 | | |
66 | config.gem 'will_paginate', :version => '= 2.3.16' | |
config.gem 'good_sort', :version => '>= 0.2.4' | ||
config.gem 'workflow', :version => '>= 0.8.0' | ||
config.gem 'activemerchant', :version => '>= 1.12.0', :lib => 'active_merchant' |
rool/rails/canvass/trunk/config/locales/en.yml:
prev. | current | |
free: "Free" | ||
ago: "ago" | ||
you: "You" | ||
120 | via: "%{one} via %{two}" # As in "Donated by 'Foo via Bar'" | |
range_from: "From" # See also the Messages controller view hint strings | ||
range_to: "to" | ||
page_menu: "Explore..." | ||
... | ... | |
view_payment_method_hint: "Payment method" | ||
view_payment_onsite_hint: "On-site with a credit or debit card" | ||
view_payment_offsite_hint: "Off-site with PayPal" | ||
227 | view_payment_none_hint: "None - register an external donation" | |
view_payment_not_stored: "Neither payment card details nor any information about a PayPal account will be stored by this site." | ||
229 | view_and_if_so_donor_name: "and if so, optional donor name:" | |
230 | view_and_donor_email: "and e-mail address:" | |
231 | view_external_note: "External donation registered by administrator" | |
view_not_tax_invoice: "This information is generated for your records. This is not a tax invoice." | ||
... | ... | |
polls: | ||
name: "Bounty" | ||
action_title_new: &new_title "Add a new bounty" | ||
304 | | |
309 | action_title_edit: &edit_title "Edit bounty details" | |
action_title_show: "Bounty details" | ||
action_title_index: "All bounties" | ||
action_title_delete: &delete_title "Delete bounty" | ||
... | ... | |
view_event_underway: "Get underway" | ||
view_event_expired: "Expire" | ||
view_event_completed: "Complete" | ||
333 | | |
338 | view_event_reverted: "Revert to Open" | |
view_menu_no_change: "No change" | ||
view_state_change_care_hint: "Take care! State changes cannot be undone." |