Commit d8556255ecac57dba7870a2dabcf4c2c032804a8
1 parent
0e71f121
Exists in
master
and in
11 other branches
Set locations for a proposal
Showing
4 changed files
with
22 additions
and
0 deletions
Show diff stats
lib/proposals_discussion_plugin/proposal.rb
... | ... | @@ -5,6 +5,8 @@ class ProposalsDiscussionPlugin::Proposal < TinyMceArticle |
5 | 5 | |
6 | 6 | belongs_to :topic, :foreign_key => :parent_id, :class_name => 'ProposalsDiscussionPlugin::Topic' |
7 | 7 | |
8 | + has_many :locations, :class_name => 'Region', :through => :article_categorizations, :source => :category | |
9 | + | |
8 | 10 | def self.short_description |
9 | 11 | _("Proposal") |
10 | 12 | end | ... | ... |
public/style.css
test/unit/proposal_test.rb
... | ... | @@ -117,4 +117,11 @@ class ProposalTest < ActiveSupport::TestCase |
117 | 117 | assert !proposal.allow_vote? |
118 | 118 | end |
119 | 119 | |
120 | + should 'set a proposal location' do | |
121 | + location = fast_create(Region) | |
122 | + proposal.save! | |
123 | + proposal.add_category(location) | |
124 | + assert_equal [location], proposal.locations | |
125 | + end | |
126 | + | |
120 | 127 | end | ... | ... |
views/content_viewer/_proposal_card.html.erb
... | ... | @@ -27,6 +27,13 @@ |
27 | 27 | <span title="<%= normalized_score %>" style="background-position-y: -<%= pos %>px"> </span> |
28 | 28 | <% end %> |
29 | 29 | </div> |
30 | + <% if proposal_card.locations.present? %> | |
31 | + <div class="locations"> | |
32 | + <% proposal_card.locations.each do |location| %> | |
33 | + <span class="location"><%= location.name %></span> | |
34 | + <% end %> | |
35 | + </div> | |
36 | + <% end %> | |
30 | 37 | <% if !proposal_card.tags.empty? %> |
31 | 38 | <div class="tags" id="article-tags"> |
32 | 39 | <%= proposal_card.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }.join("\n") %> | ... | ... |