diff options
| -rw-r--r-- | app/controllers/calendars_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/calendar.rb | 4 | ||||
| -rw-r--r-- | app/policies/calendar_policy.rb | 3 | ||||
| -rw-r--r-- | app/views/calendars/index.html.slim | 1 | 
4 files changed, 3 insertions, 7 deletions
| diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 579a48e1d..81eb029a6 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -1,6 +1,6 @@  class CalendarsController < BreadcrumbController    defaults resource_class: Calendar -  before_action :check_policy, only: [:edit, :update, :destroy] +  before_action :check_policy, except: [:index, :new, :create]    respond_to :html    respond_to :js, only: :index diff --git a/app/models/calendar.rb b/app/models/calendar.rb index d616bce10..e1181fe5f 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -8,7 +8,7 @@ class Calendar < ActiveRecord::Base    scope :contains_date, ->(date) { where('date ? = any (dates) OR date ? <@ any (date_ranges)', date, date) }    scope :shared, -> { where(shared: true) } -  scope :by_organisation(org_id), -> { where(organisation_id: org_id) } +  scope :by_organisation, ->(org_id) { where(organisation_id: org_id) }    def init_dates_and_date_ranges      self.dates ||= [] @@ -19,8 +19,6 @@ class Calendar < ActiveRecord::Base      [:contains_date]    end -  private_class_method :ransackable_scopes -    class Period      include ActiveAttr::Model diff --git a/app/policies/calendar_policy.rb b/app/policies/calendar_policy.rb index d340bfdda..f1f8ebad4 100644 --- a/app/policies/calendar_policy.rb +++ b/app/policies/calendar_policy.rb @@ -27,7 +27,6 @@ class CalendarPolicy < ApplicationPolicy    end    def organisation_match? -    true -    #current_organisation == record.organisation +    user.organisation == record.organisation    end  end diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim index 9696e3c0b..9dd638681 100644 --- a/app/views/calendars/index.html.slim +++ b/app/views/calendars/index.html.slim @@ -25,6 +25,5 @@  - content_for :sidebar do    ul.actions      li -    - if policy(Calendar).create?        = link_to t('calendars.actions.new'), new_calendar_path, class: 'add'      br | 
