diff options
| author | Zog | 2017-12-18 17:18:25 +0100 | 
|---|---|---|
| committer | Zog | 2017-12-19 14:21:52 +0100 | 
| commit | 98c08c6fae5b0bf59231b3e402ca91307c200297 (patch) | |
| tree | 51dc7a30198d6fa83df13948fc2223effb01cc28 /app/policies | |
| parent | 3aa5ff0d1f5e74b4c46c14e6240e7def82f0451d (diff) | |
| download | chouette-core-98c08c6fae5b0bf59231b3e402ca91307c200297.tar.bz2 | |
Refs #5333@1.5h; Use permissions to sync StopAreas and Lines
- add missing policies
- update permissions translator
- update views to check for the permission
- update views helper to check for the permission
- uipdate controllers to check for the permission
Diffstat (limited to 'app/policies')
| -rw-r--r-- | app/policies/calendar_policy.rb | 17 | ||||
| -rw-r--r-- | app/policies/line_referential_policy.rb | 14 | ||||
| -rw-r--r-- | app/policies/stop_area_referential_policy.rb | 14 | 
3 files changed, 35 insertions, 10 deletions
| diff --git a/app/policies/calendar_policy.rb b/app/policies/calendar_policy.rb index 074c41d8d..3ba708ec9 100644 --- a/app/policies/calendar_policy.rb +++ b/app/policies/calendar_policy.rb @@ -5,18 +5,15 @@ class CalendarPolicy < ApplicationPolicy      end    end -  def create?  +  def create?      !archived? && user.has_permission?('calendars.create')    end -  def destroy? -    !archived? & organisation_match? && user.has_permission?('calendars.destroy') -  end -  def update? -    !archived? && organisation_match? && user.has_permission?('calendars.update') -  end +  def destroy?; instance_permission("destroy") end +  def update?; instance_permission("update") end +  def share?; instance_permission("share") end -  def share? -    user.organisation.name == 'STIF' # FIXME +  private +  def instance_permission permission +    !archived? & organisation_match? && user.has_permission?("calendars.#{permission}")    end -  end diff --git a/app/policies/line_referential_policy.rb b/app/policies/line_referential_policy.rb new file mode 100644 index 000000000..ee742a083 --- /dev/null +++ b/app/policies/line_referential_policy.rb @@ -0,0 +1,14 @@ +class LineReferentialPolicy < ApplicationPolicy +  class Scope < Scope +    def resolve +      scope +    end +  end + +  def synchronize?; instance_permission("synchronize") end + +  private +  def instance_permission permission +    user.has_permission?("line_referentials.#{permission}") +  end +end diff --git a/app/policies/stop_area_referential_policy.rb b/app/policies/stop_area_referential_policy.rb new file mode 100644 index 000000000..e370babf8 --- /dev/null +++ b/app/policies/stop_area_referential_policy.rb @@ -0,0 +1,14 @@ +class StopAreaReferentialPolicy < ApplicationPolicy +  class Scope < Scope +    def resolve +      scope +    end +  end + +  def synchronize?; instance_permission("synchronize") end + +  private +  def instance_permission permission +    user.has_permission?("stop_area_referentials.#{permission}") +  end +end | 
