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,6 +5,8 @@ class ProposalsDiscussionPlugin::Proposal < TinyMceArticle
5 5
6 belongs_to :topic, :foreign_key => :parent_id, :class_name => 'ProposalsDiscussionPlugin::Topic' 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 def self.short_description 10 def self.short_description
9 _("Proposal") 11 _("Proposal")
10 end 12 end
public/style.css
@@ -40,6 +40,12 @@ @@ -40,6 +40,12 @@
40 float: left; 40 float: left;
41 clear: both; 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 .proposal .author { 49 .proposal .author {
44 display: table-cell; 50 display: table-cell;
45 font-size: 10px; 51 font-size: 10px;
test/unit/proposal_test.rb
@@ -117,4 +117,11 @@ class ProposalTest < ActiveSupport::TestCase @@ -117,4 +117,11 @@ class ProposalTest < ActiveSupport::TestCase
117 assert !proposal.allow_vote? 117 assert !proposal.allow_vote?
118 end 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 end 127 end
views/content_viewer/_proposal_card.html.erb
@@ -27,6 +27,13 @@ @@ -27,6 +27,13 @@
27 <span title="<%= normalized_score %>" style="background-position-y: -<%= pos %>px">&nbsp;</span> 27 <span title="<%= normalized_score %>" style="background-position-y: -<%= pos %>px">&nbsp;</span>
28 <% end %> 28 <% end %>
29 </div> 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 <% if !proposal_card.tags.empty? %> 37 <% if !proposal_card.tags.empty? %>
31 <div class="tags" id="article-tags"> 38 <div class="tags" id="article-tags">
32 <%= proposal_card.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }.join("\n") %> 39 <%= proposal_card.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }.join("\n") %>