Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 464
- Log:
Canvass version 1.0.2.
- Author:
- rool
- Date:
- Sat May 03 09:48:48 +0100 2014
- Size:
- 2622 Bytes
1 | ######################################################################## |
2 | # File:: donations_helper.rb |
3 | # (C):: Hipposoft 2011 |
4 | # |
5 | # Purpose:: Utility methods for views related to Donations. |
6 | # ---------------------------------------------------------------------- |
7 | # 22-Feb-2011 (ADH): Created. |
8 | ######################################################################## |
9 | |
10 | module DonationsHelper |
11 | |
12 | # Return text suitable for a link, button or heading when wanting to list |
13 | # donations restricted by the given User or user ID - e.g. "Your donations" |
14 | # vs "<Foo>'s donations" if a user ID specifies the current user or another |
15 | # user. Pass "nil" for a generic string - e.g. "All donations". |
16 | # |
17 | # The returned string is HTML-safe, with any sensitive characters escaped. |
18 | # |
19 | def donationshelp_index_text( user_or_id ) |
20 | user_or_id = User.find_by_id( user_or_id ) unless ( user_or_id.is_a? User ) |
21 | |
22 | if ( user_or_id.nil? ) |
23 | apphelp_heading( DonationsController, :index ) |
24 | elsif ( user_or_id.id == current_user.try( :id ) ) |
25 | apphelp_view_hint( :your_donations, DonationsController ) |
26 | else |
27 | apphelp_view_hint( :other_donations, DonationsController, :name => h( user_or_id.name ) ) |
28 | end |
29 | end |
30 | |
31 | # Return an HTML-safe description of a user's name from a given Donation |
32 | # record, linking to the Users Controller's "show" action for that User if |
33 | # the object still exists. |
34 | # |
35 | def donationshelp_user_link( donation ) |
36 | if ( donation.user.nil? ) |
37 | 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() |
44 | else |
45 | link_to( h( donation.user_name ), donation.user ) |
46 | end |
47 | end |
48 | |
49 | # Return an HTML-safe description of a poll's title from a given Donation |
50 | # record, linking to the Polls Controller's "show" action for that Poll if |
51 | # the object still exists. |
52 | # |
53 | def donationshelp_poll_link( donation ) |
54 | if ( donation.poll.nil? ) |
55 | h( donation.poll_title ) |
56 | else |
57 | link_to( h( donation.poll_title ), donation.poll ) |
58 | end |
59 | end |
60 | |
61 | # As "donationshelp_poll_link" but handles the slightly more fiddly case of |
62 | # the source poll for redistribution credit donations. |
63 | # |
64 | def donationshelp_source_poll_link( donation ) |
65 | if ( Poll.find_by_id( donation.source_poll_id ).nil? ) |
66 | h( donation.source_poll_title ) |
67 | else |
68 | link_to( h( donation.source_poll_title ), poll_path( :id => donation.source_poll_id ) ) |
69 | end |
70 | end |
71 | |
72 | end |