diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/announcement.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/announcement.rb b/app/models/announcement.rb index 670b24f01..d99502f44 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -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 |