Class: ApplicationPolicy

Inherits:
Object
  • Object
show all
Defined in:
app/policies/application_policy.rb

Instance Method Summary collapse

Instance Method Details

#classroom_rosterer_light?Boolean (private)

Returns:

  • (Boolean)


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)

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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)

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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)

Returns:

  • (Boolean)


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