Add publish/unpublish controls to announcements in admin UI (#12967)
This commit is contained in:
parent
4363d06986
commit
663ea84b08
7 changed files with 49 additions and 7 deletions
|
@ -32,6 +32,14 @@ class Announcement < ApplicationRecord
|
|||
before_validation :set_all_day
|
||||
before_validation :set_published, on: :create
|
||||
|
||||
def publish!
|
||||
update!(published: true, published_at: Time.now.utc, scheduled_at: nil)
|
||||
end
|
||||
|
||||
def unpublish!
|
||||
update!(published: false, scheduled_at: nil)
|
||||
end
|
||||
|
||||
def time_range?
|
||||
starts_at.present? && ends_at.present?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue