FIX: prevents name collision by namespacing guardian method

FIX: prevents name collision by namespacing guardian method

diff --git a/app/controllers/discourse_post_event/events_controller.rb b/app/controllers/discourse_post_event/events_controller.rb
index 7c080d9..b13557a 100644
--- a/app/controllers/discourse_post_event/events_controller.rb
+++ b/app/controllers/discourse_post_event/events_controller.rb
@@ -24,7 +24,7 @@ module DiscoursePostEvent
 
     def invite
       event = Event.find(params[:id])
-      guardian.ensure_can_act_on_event!(event)
+      guardian.ensure_can_act_on_discourse_post_event!(event)
       invites = Array(params.permit(invites: [])[:invites])
       users = Invitee.extract_uniq_usernames(invites)
 
@@ -44,7 +44,7 @@ module DiscoursePostEvent
 
     def destroy
       event = Event.find(params[:id])
-      guardian.ensure_can_act_on_event!(event)
+      guardian.ensure_can_act_on_discourse_post_event!(event)
       event.publish_update!
       event.destroy
       render json: success_json
@@ -54,7 +54,7 @@ module DiscoursePostEvent
       DistributedMutex.synchronize("discourse-post-event[event-update]") do
         event = Event.find(params[:id])
         guardian.ensure_can_edit!(event.post)
-        guardian.ensure_can_act_on_event!(event)
+        guardian.ensure_can_act_on_discourse_post_event!(event)
         event.update_with_params!(event_params)
         serializer = EventSerializer.new(event, scope: guardian)
         render_json_dump(serializer)
@@ -64,7 +64,7 @@ module DiscoursePostEvent
     def create
       event = Event.new(event_params)
       guardian.ensure_can_edit!(event.post)
-      guardian.ensure_can_create_event!
+      guardian.ensure_can_create_discourse_post_event!
       event.enforce_utc!(event_params)
 
       case event_params[:status].to_i
diff --git a/app/controllers/discourse_post_event/invitees_controller.rb b/app/controllers/discourse_post_event/invitees_controller.rb
index 1c75e9a..661bed9 100644
--- a/app/controllers/discourse_post_event/invitees_controller.rb
+++ b/app/controllers/discourse_post_event/invitees_controller.rb
@@ -32,7 +32,7 @@ module DiscoursePostEvent
     def create
       status = Invitee.statuses[invitee_params[:status].to_sym]
       event = Event.find(invitee_params[:post_id])
-      guardian.ensure_can_act_on_event!(event)
+      guardian.ensure_can_act_on_discourse_post_event!(event)
       invitee = Invitee.create!(
         status: status,
         post_id: invitee_params[:post_id],
diff --git a/app/serializers/discourse_post_event/event_serializer.rb b/app/serializers/discourse_post_event/event_serializer.rb
index 624e245..83fbe26 100644
--- a/app/serializers/discourse_post_event/event_serializer.rb
+++ b/app/serializers/discourse_post_event/event_serializer.rb
@@ -13,13 +13,13 @@ module DiscoursePostEvent
     attributes :raw_invitees
     attributes :post
     attributes :name
-    attributes :can_act_on_event
+    attributes :can_act_on_discourse_post_event
     attributes :can_update_attendance
     attributes :is_expired
     attributes :should_display_invitees
 
-    def can_act_on_event
-      scope.can_act_on_event?(object)
+    def can_act_on_discourse_post_event
+      scope.can_act_on_discourse_post_event?(object)
     end
 
     def is_expired
diff --git a/assets/javascripts/discourse/widgets/discourse-post-event.js.es6 b/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
index f6fbe05..6cf0745 100644
--- a/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
+++ b/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
@@ -150,7 +150,7 @@ export default createWidget("discourse-post-event", {
           </div>
         </div>
 
-        {{#if state.eventModel.can_act_on_event}}
+        {{#if state.eventModel.can_act_on_discourse_post_event}}
           <div class="actions">
             {{attach
               widget="button"
@@ -204,7 +204,7 @@ export default createWidget("discourse-post-event", {
         }}
 
         {{#unless state.eventModel.is_expired}}
-        {{#if state.eventModel.can_act_on_event}}
+        {{#if state.eventModel.can_act_on_discourse_post_event}}
         {{#if transformed.isPublicEvent}}
           {{attach
             widget="button"
diff --git a/assets/javascripts/initializers/add-event-ui-builder.js.es6 b/assets/javascripts/initializers/add-event-ui-builder.js.es6
index 29d034f..bc21ac3 100644
--- a/assets/javascripts/initializers/add-event-ui-builder.js.es6
+++ b/assets/javascripts/initializers/add-event-ui-builder.js.es6
@@ -7,7 +7,7 @@ function initializeEventBuilder(api) {
   api.onToolbarCreate(toolbar => {
     if (
       !currentUser ||
-      !currentUser.can_create_event ||
+      !currentUser.can_create_discourse_post_event ||
       !toolbar.context.outletArgs
     ) {
       return;
diff --git a/lib/discourse_post_event/event_validator.rb b/lib/discourse_post_event/event_validator.rb
index 38ad44a..3f9d329 100644
--- a/lib/discourse_post_event/event_validator.rb
+++ b/lib/discourse_post_event/event_validator.rb
@@ -26,12 +26,12 @@ module DiscoursePostEvent
       extracted_event = extracted_events.first
 
       if @post.acting_user && @post.event
-        if !@post.acting_user.can_act_on_event?(@post.event)
+        if !@post.acting_user.can_act_on_discourse_post_event?(@post.event)
           @post.errors.add(:base, I18n.t("discourse_post_event.errors.models.event.acting_user_not_allowed_to_act_on_this_event"))
           return false
         end
       else
-        if !@post.acting_user || !@post.acting_user.can_create_event?
+        if !@post.acting_user || !@post.acting_user.can_create_discourse_post_event?
           @post.errors.add(:base, I18n.t("discourse_post_event.errors.models.event.acting_user_not_allowed_to_create_event"))
           return false
         end
diff --git a/plugin.rb b/plugin.rb
index 5a4a32d..397bdc7 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -126,9 +126,9 @@ after_initialize do
     end
   end
 
-  add_to_class(:user, :can_create_event?) do
-    return @can_create_event if defined?(@can_create_event)
-    @can_create_event = begin
+  add_to_class(:user, :can_create_discourse_post_event?) do
+    return @can_create_discourse_post_event if defined?(@can_create_discourse_post_event)
+    @can_create_discourse_post_event = begin
       return true if staff?
       allowed_groups = SiteSetting.discourse_post_event_allowed_on_groups.split('|').compact
       allowed_groups.present? && groups.where(id: allowed_groups).exists?
@@ -141,23 +141,23 @@ after_initialize do
     user && (user.staff? || user.id == invitee.user_id)
   end
 
-  add_to_class(:guardian, :can_create_event?) { user && user.can_create_event? }
+  add_to_class(:guardian, :can_create_discourse_post_event?) { user && user.can_create_discourse_post_event? }
 
-  add_to_serializer(:current_user, :can_create_event) do
-    object.can_create_event?
+  add_to_serializer(:current_user, :can_create_discourse_post_event) do
+    object.can_create_discourse_post_event?
   end
 
-  add_to_class(:user, :can_act_on_event?) do |event|
-    return @can_act_on_event if defined?(@can_act_on_event)
-    @can_act_on_event = begin
+  add_to_class(:user, :can_act_on_discourse_post_event?) do |event|
+    return @can_act_on_discourse_post_event if defined?(@can_act_on_discourse_post_event)
+    @can_act_on_discourse_post_event = begin
       return true if admin?
-      can_create_event? && event.post.user_id == id
+      can_create_discourse_post_event? && event.post.user_id == id
     rescue
       false
     end
   end
 
-  add_to_class(:guardian, :can_act_on_event?) { |event| user && user.can_act_on_event?(event) }
+  add_to_class(:guardian, :can_act_on_discourse_post_event?) { |event| user && user.can_act_on_discourse_post_event?(event) }
 
   add_class_method(:group, :discourse_post_event_allowed_groups) do
     where(id: SiteSetting.discourse_post_event_allowed_on_groups.split('|').compact)

GitHub sha: cc193bf2