Commit d8556255ecac57dba7870a2dabcf4c2c032804a8

Authored by Victor Costa
1 parent 0e71f121

Set locations for a proposal

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
... ... @@ -40,6 +40,12 @@
40 40 float: left;
41 41 clear: both;
42 42 }
  43 +.proposals_list .proposal .locations {
  44 + float: right;
  45 + clear: both;
  46 + color: rgb(155, 155, 155);
  47 + font-weight: bold;
  48 +}
43 49 .proposal .author {
44 50 display: table-cell;
45 51 font-size: 10px;
... ...
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">&nbsp;</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") %>
... ...