mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
ensures only one banner topic at all time
This commit is contained in:
@ -626,6 +626,22 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def make_banner!(user)
|
||||
# only one banner at the same time
|
||||
previous_banner = Topic.where(archetype: Archetype.banner).first
|
||||
previous_banner.remove_banner!(user) if previous_banner.present?
|
||||
|
||||
self.archetype = Archetype.banner
|
||||
self.add_moderator_post(user, I18n.t("archetypes.banner.message.make"))
|
||||
self.save
|
||||
end
|
||||
|
||||
def remove_banner!(user)
|
||||
self.archetype = Archetype.default
|
||||
self.add_moderator_post(user, I18n.t("archetypes.banner.message.remove"))
|
||||
self.save
|
||||
end
|
||||
|
||||
def self.starred_counts_per_day(sinceDaysAgo=30)
|
||||
TopicUser.starred_since(sinceDaysAgo).by_date_starred.count
|
||||
end
|
||||
|
Reference in New Issue
Block a user