Add community to investments
This commit is contained in:
20
app/helpers/communities_helper.rb
Normal file
20
app/helpers/communities_helper.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module CommunitiesHelper
|
||||
|
||||
def community_title(community)
|
||||
if community.from_proposal?
|
||||
community.proposal.title
|
||||
else
|
||||
investment = Budget::Investment.where(community_id: community.id).first
|
||||
investment.title
|
||||
end
|
||||
end
|
||||
|
||||
def community_text(community)
|
||||
community.from_proposal? ? t("community.show.title.proposal") : t("community.show.title.investment")
|
||||
end
|
||||
|
||||
def community_description(community)
|
||||
community.from_proposal? ? t("community.show.description.proposal") : t("community.show.description.investment")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -21,6 +21,7 @@ class Budget
|
||||
belongs_to :group
|
||||
belongs_to :budget
|
||||
belongs_to :administrator
|
||||
belongs_to :community
|
||||
|
||||
has_many :valuator_assignments, dependent: :destroy
|
||||
has_many :valuators, through: :valuator_assignments
|
||||
@@ -71,6 +72,7 @@ class Budget
|
||||
|
||||
before_save :calculate_confidence_score
|
||||
after_save :recalculate_heading_winners if :incompatible_changed?
|
||||
before_create :associate_community
|
||||
before_validation :set_responsible_name
|
||||
before_validation :set_denormalized_ids
|
||||
|
||||
@@ -258,6 +260,11 @@ class Budget
|
||||
investments
|
||||
end
|
||||
|
||||
def associate_community
|
||||
community = Community.create
|
||||
self.community_id = community.id
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
|
||||
@@ -6,4 +6,9 @@ class Community < ActiveRecord::Base
|
||||
def participants
|
||||
User.community_participants(self)
|
||||
end
|
||||
|
||||
def from_proposal?
|
||||
self.proposal.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -123,6 +123,13 @@
|
||||
<%= render 'follows/follow_button', follow: find_or_build_follow(current_user, investment) %>
|
||||
<% end %>
|
||||
|
||||
<div class="sidebar-divider"></div>
|
||||
<h2><%= t("community.sidebar.title") %></h2>
|
||||
<p>
|
||||
<%= t("community.sidebar.description") %>
|
||||
</p>
|
||||
<%= link_to t("community.sidebar.button_to_access"), community_path(investment.community_id), class: 'button hollow expanded' %>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<div class="jumbo light">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<h2><%= t("community.show.title") %></h2>
|
||||
<p class="lead"> <%= @community.proposal.title %> </p>
|
||||
<p><%= t("community.show.description") %> </p>
|
||||
<h2><%= community_text(@community) %></h2>
|
||||
<p class="lead"> <%= community_title(@community) %> </p>
|
||||
<p><%= community_description(@community) %> </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<%= render "shared/back_link" %>
|
||||
<br>
|
||||
|
||||
<p><%= t("community.topic.show.community_of_the_proposal") %> <strong><%= @community.proposal.title %></strong></p>
|
||||
<p><%= t("community.topic.show.community_of_the_proposal") %> <strong><%= community_title(@community) %></strong></p>
|
||||
<h1><%= @topic.title %></h1>
|
||||
<div class="topic-info">
|
||||
<p><%= @topic.description %></p>
|
||||
|
||||
Reference in New Issue
Block a user