minor refactorings
This commit is contained in:
parent
d7817cf314
commit
e5e904aa4e
|
@ -215,7 +215,7 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def private_message?
|
def private_message?
|
||||||
self.archetype == Archetype.private_message
|
archetype == Archetype.private_message
|
||||||
end
|
end
|
||||||
|
|
||||||
def links_grouped
|
def links_grouped
|
||||||
|
@ -532,10 +532,8 @@ class Topic < ActiveRecord::Base
|
||||||
def feature_topic_users(args={})
|
def feature_topic_users(args={})
|
||||||
reload
|
reload
|
||||||
|
|
||||||
to_feature = posts
|
|
||||||
|
|
||||||
# Don't include the OP or the last poster
|
# Don't include the OP or the last poster
|
||||||
to_feature = to_feature.where('user_id NOT IN (?, ?)', user_id, last_post_user_id)
|
to_feature = posts.where('user_id NOT IN (?, ?)', user_id, last_post_user_id)
|
||||||
|
|
||||||
# Exclude a given post if supplied (in the case of deletes)
|
# Exclude a given post if supplied (in the case of deletes)
|
||||||
to_feature = to_feature.where("id <> ?", args[:except_post_id]) if args[:except_post_id].present?
|
to_feature = to_feature.where("id <> ?", args[:except_post_id]) if args[:except_post_id].present?
|
||||||
|
@ -633,7 +631,7 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.starred_counts_per_day(sinceDaysAgo=30)
|
def self.starred_counts_per_day(sinceDaysAgo=30)
|
||||||
TopicUser.where('starred_at > ?', sinceDaysAgo.days.ago).group('date(starred_at)').order('date(starred_at)').count
|
TopicUser.starred_since(sinceDaysAgo).by_date_starred.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def slug
|
def slug
|
||||||
|
@ -721,7 +719,8 @@ class Topic < ActiveRecord::Base
|
||||||
|
|
||||||
def auto_close_days=(num_days)
|
def auto_close_days=(num_days)
|
||||||
@ignore_category_auto_close = true
|
@ignore_category_auto_close = true
|
||||||
self.auto_close_at = (num_days and num_days.to_i > 0.0 ? num_days.to_i.days.from_now : nil)
|
num_days = num_days.to_i
|
||||||
|
self.auto_close_at = (num_days > 0 ? num_days.days.from_now : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def secure_category?
|
def secure_category?
|
||||||
|
|
|
@ -2,6 +2,9 @@ class TopicUser < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :topic
|
belongs_to :topic
|
||||||
|
|
||||||
|
scope :starred_since, lambda { |sinceDaysAgo| where('starred_at > ?', sinceDaysAgo.days.ago) }
|
||||||
|
scope :by_date_starred, group('date(starred_at)').order('date(starred_at)')
|
||||||
|
|
||||||
# Class methods
|
# Class methods
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ class Guardian
|
||||||
alias :can_activate? :can_approve?
|
alias :can_activate? :can_approve?
|
||||||
|
|
||||||
def can_ban?(user)
|
def can_ban?(user)
|
||||||
user && is_staff? && not(user.staff?)
|
user && is_staff? && user.regular?
|
||||||
end
|
end
|
||||||
alias :can_deactivate? :can_ban?
|
alias :can_deactivate? :can_ban?
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue