Merge branch 'master' into polling-views-plus
This commit is contained in:
@@ -44,9 +44,13 @@ 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.sort_by_confidence_score }
|
||||
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) }
|
||||
scope :successfull, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)}
|
||||
|
||||
def to_param
|
||||
"#{id}-#{title}".parameterize
|
||||
@@ -119,7 +123,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 +159,14 @@ class Proposal < ActiveRecord::Base
|
||||
Setting['votes_for_proposal_success'].to_i
|
||||
end
|
||||
|
||||
def successfull?
|
||||
total_votes >= Proposal.votes_needed_for_success
|
||||
end
|
||||
|
||||
def archived?
|
||||
self.created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
end
|
||||
|
||||
def notifications
|
||||
proposal_notifications
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class User < ActiveRecord::Base
|
||||
|
||||
include Verification
|
||||
|
||||
devise :database_authenticatable, :registerable, :confirmable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :async
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable,
|
||||
:trackable, :validatable, :omniauthable, :async, :password_expirable, :secure_validatable
|
||||
|
||||
acts_as_voter
|
||||
acts_as_paranoid column: :hidden_at
|
||||
|
||||
Reference in New Issue
Block a user