Creates archived proposals method

This commit is contained in:
Alberto Garcia Cabeza
2016-09-09 17:31:05 +02:00
parent 9c2f5e3944
commit 41312ca2a5
2 changed files with 7 additions and 1 deletions

View File

@@ -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

View File

@@ -44,6 +44,8 @@ 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 <= ?", 12.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) }
@@ -155,6 +157,10 @@ class Proposal < ActiveRecord::Base
Setting['votes_for_proposal_success'].to_i
end
def archived?
self.created_at <= 12.months.ago
end
def notifications
proposal_notifications
end