diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index f7e5d6f..9288a93 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -635,6 +635,7 @@ class Admin::AnnouncementsController < OrbitAdminController params.require(:announcement_setting).permit! end def update_calendar(bps,bulletin) + bps = bps.to_h.with_indifferent_access if bps[:add_to_calendar] == '0' && !bps[:event_id].blank? Event.find(bps[:event_id]).destroy rescue nil bps[:event_id] = nil diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 6f97869..1e3d99a 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -38,6 +38,9 @@ class Bulletin SubPart.class_eval { include BulletinModel::Cache } Page.class_eval { include BulletinModel::Cache } before_destroy do + if self.event_id.present? && !defined?(Calendar).nil? + Event.where(:id=>self.event_id).destroy + end AnnsCache.all.destroy end field :is_edit, type: Boolean, default: false #use to check whether the preview record changed