Class: ApplicationPolicy
- Inherits:
-
Object
- Object
- ApplicationPolicy
- Defined in:
- app/policies/application_policy.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#classroom_rosterer_light? ⇒ Boolean
private
#omniscient_mode? or #teacher? or #school_leader_rosterer? or #district_leader?.
-
#district_leader? ⇒ Boolean
Is district leader in provided context (Classroom, School or District).
-
#enterprise_manageable? ⇒ Boolean
private
School is not premium OR Premium School with enabled manual roster editing.
-
#enterprise_syncable? ⇒ Boolean
private
Returns true when School has connector and SIS sync is enabled or if School has ES in District context with enabled Sync.
-
#school_leader_rosterer? ⇒ Boolean
Has rostering admin permission in current school.
-
#teacher? ⇒ Boolean
private
Has a ClassMembership#teacher in provided context (Classroom, School or District).
Instance Method Details
#classroom_rosterer_light? ⇒ Boolean (private)
#omniscient_mode? or #teacher? or #school_leader_rosterer? or #district_leader?
188 189 190 |
# File 'app/policies/application_policy.rb', line 188 def classroom_rosterer_light? omniscient_mode? || teacher? || school_leader_rosterer? || district_leader? end |
#district_leader? ⇒ Boolean
Is district leader in provided context (Classroom, School or District)
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/policies/application_policy.rb', line 36 def district_leader? @district_leader ||= leadership_exists = DistrictLeadership.exists?(user:) if record.is_a?(Class) leadership_exists elsif leadership_exists # Optimized to avoid huge district_id: nil search user_district_schools.exists?(id: record_schools) || user_district_classrooms.exists?(id: record_classrooms) else false end end |
#enterprise_manageable? ⇒ Boolean (private)
School is not premium OR Premium School with enabled manual roster editing
116 117 118 |
# File 'app/policies/application_policy.rb', line 116 def enterprise_manageable? !premium_school? || manual_roster_editing? end |
#school_leader_rosterer? ⇒ Boolean
Has rostering admin permission in current school
98 99 100 |
# File 'app/policies/application_policy.rb', line 98 def school_leader_rosterer? SchoolLeadership.rostering_admin.exists?(user:, school: record_schools) end |
#teacher? ⇒ Boolean (private)
Has a ClassMembership#teacher in provided context (Classroom, School or District)
278 279 280 281 282 |
# File 'app/policies/application_policy.rb', line 278 def teacher? return user_class_memberships.teacher.exists? if record.is_a?(Class) shared_class_memberships.teacher.exists? end |
#enterprise_syncable? ⇒ Boolean (private)
Returns true when School has connector and SIS sync is enabled or if School has ES in District context with enabled Sync
135 136 137 138 139 140 |
# File 'app/policies/application_policy.rb', line 135 def enterprise_syncable? return false if premium_sis_syncing_school.blank? return true if sis_connector.sis_connectable_type == 'School' premium_sis_syncing_school.external_sources.send(sis_connector.connector_type).exists? end |
#school_leader_rosterer? ⇒ Boolean
Has rostering admin permission in current school
98 99 100 |
# File 'app/policies/application_policy.rb', line 98 def school_leader_rosterer? SchoolLeadership.rostering_admin.exists?(user:, school: record_schools) end |
#teacher? ⇒ Boolean (private)
Has a ClassMembership#teacher in provided context (Classroom, School or District)
281 282 283 284 285 |
# File 'app/policies/application_policy.rb', line 281 def teacher? return user_class_memberships.teacher.exists? if record.is_a?(Class) shared_class_memberships.teacher.exists? end |