diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index ffe08617f..2ab28f52d 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -269,6 +269,21 @@ } } +.message { + @include supports; + background: none; + border-top: 0; + + @include breakpoint(medium) { + border-left: 1px solid $border; + margin: $line-height rem-calc(-25) 0 rem-calc(12); + } + + p { + font-size: $small-font-size; + } +} + // 02. New participation // --------------------- diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 3a79238ea..3f4398797 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -12,7 +12,7 @@ module CommentableActions @tag_cloud = tag_cloud @banners = Banner.with_active - + set_resource_votes(@resources) set_resources_instance end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 578395ab3..7b3ccafe7 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -12,7 +12,7 @@ class ProposalsController < ApplicationController invisible_captcha only: [:create, :update], honeypot: :subtitle - has_orders %w{hot_score confidence_score created_at relevance}, only: :index + has_orders %w{hot_score confidence_score created_at relevance archival_date}, only: :index has_orders %w{most_voted newest oldest}, only: :show load_and_authorize_resource @@ -26,6 +26,7 @@ class ProposalsController < ApplicationController end def index_customization + discard_archived load_retired load_featured end @@ -80,6 +81,10 @@ class ProposalsController < ApplicationController @featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {} end + def discard_archived + @resources = @resources.not_archived unless @current_order == "archival_date" + end + def load_retired if params[:retired].present? @resources = @resources.retired @@ -90,7 +95,7 @@ class ProposalsController < ApplicationController end def load_featured - @featured_proposals = Proposal.all.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?) + @featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?) if @featured_proposals.present? set_featured_proposal_votes(@featured_proposals) @resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id)) diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 9a92a8d18..91b01f785 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -44,6 +44,9 @@ class Proposal < ActiveRecord::Base scope :sort_by_random, -> { reorder("RANDOM()") } scope :sort_by_relevance, -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } + scope :sort_by_archival_date, -> { archived.order(created_at: :desc) } + scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago)} + scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago)} scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } @@ -119,7 +122,7 @@ class Proposal < ActiveRecord::Base end def register_vote(user, vote_value) - if votable_by?(user) + if votable_by?(user) && !archived? vote_by(voter: user, vote: vote_value) end end @@ -155,6 +158,10 @@ class Proposal < ActiveRecord::Base Setting['votes_for_proposal_success'].to_i end + def archived? + self.created_at <= Setting["months_to_archive_proposals"].to_i.months.ago + end + def notifications proposal_notifications end diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 70c2b9c89..4b6f27cbc 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -50,9 +50,18 @@ -
- <%= render 'votes', - { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% if proposal.archived? %> +
+ <%= t("proposals.proposal.supports", count: proposal.total_votes) %> +

<%= t("proposals.proposal.archived") %>

+
+ <% else %> +
+ <%= render 'votes', + { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% end %>
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 6f6516890..9e0da05a8 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -30,7 +30,7 @@ <% if has_banners %> <%= render "shared/banner" %> <% end %> - + <% if @featured_proposals.present? %>
diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 3a9869d83..617c11d79 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -102,12 +102,19 @@