<?xml version="1.0"?>
<configure xmlns="http://schooltool.org/securitypolicy"
           xmlns:zope="http://namespaces.zope.org/zope"
           i18n_domain="schooltool">

  <!-- Security -->

  <crowd
      name="person_instructors"
      factory="schooltool.course.section.PersonInstructorsCrowd" />

  <crowd
      name="section_instructors"
      factory="schooltool.course.section.InstructorsCrowd" />

  <crowd
      name="section_learners"
      factory=".section.LearnersCrowd" />

  <crowd
      name="configurable_section_viewers"
      factory=".section.SectionCalendarSettingCrowd" />

  <allow
      interface="schooltool.course.interfaces.ISectionContainer"
      crowds="administrators clerks configurable_section_viewers"
      permission="schooltool.view" />
  <allow
      interface="schooltool.course.interfaces.ISectionContainer"
      crowds="clerks"
      permission="schooltool.edit" />

  <allow
      interface="schooltool.course.interfaces.ISection"
      crowds="administrators clerks teachers section_instructors section_learners configurable_section_viewers"
      permission="schooltool.view" />

  <setting
      key="instructors_can_edit_section"
      text="Section instructors can modify section's title, schedule, roster, equipment and so on."
      alt_text="Only clerks can modify the section."
      default="True" />

  <crowd
      name="configurable_section_editors"
      factory=".section.SectionEditorSettingCrowd" />

  <allow
      interface="schooltool.course.interfaces.ISection"
      crowds="clerks configurable_section_editors"
      permission="schooltool.edit" />

  <setting
      key="everyone_can_view_section_info"
      text="Basic information about sections, including rosters, is visible to the general public."
      alt_text="Basic information about sections is only visible to instructors and students in that section, and school administration."
      default="False" />

  <allow
      interface="schooltool.course.interfaces.ICourseContainer"
      crowds="everybody"
      permission="schooltool.view" />
  <allow
      interface="schooltool.course.interfaces.ICourseContainer"
      crowds="clerks managers"
      permission="schooltool.edit" />

  <allow
      interface="schooltool.course.interfaces.ICourseContainerContainer"
      crowds="clerks managers"
      permission="schooltool.edit" />

  <allow
      interface="schooltool.course.interfaces.ICourse"
      crowds="everybody"
      permission="schooltool.view" />
  <allow
      interface="schooltool.course.interfaces.ICourse"
      crowds="clerks managers leaders"
      permission="schooltool.edit" />

  <!-- Grant read access to person's data to his instructors -->
  <allow
      interface="schooltool.person.interfaces.IPerson"
      crowds="person_instructors"
      permission="schooltool.view" />

  <!-- Security descriptions -->

  <describe_group name="schooltool.course-courses"
      title="Courses"
      description="A course in SchoolTool describes a set curriculum taught in a section."
  />

  <describe_action
      group="schooltool.course-courses" name="list" title="List"
      order="10"
      interface="schooltool.course.interfaces.ICourseContainer"
      permission="schooltool.view"
  />

  <describe_action
      group="schooltool.course-courses" name="create_delete" title="Create/Delete"
      order="20"
      interface="schooltool.course.interfaces.ICourseContainer"
      permission="schooltool.edit"
  />

  <describe_action
      group="schooltool.course-courses" name="view" title="View"
      order="30"
      interface="schooltool.course.interfaces.ICourse"
      permission="schooltool.view"
  />

  <describe_action
      group="schooltool.course-courses" name="modify" title="Modify"
      order="40"
      interface="schooltool.course.interfaces.ICourse"
      permission="schooltool.edit"
  />

  <describe_group name="schooltool.course-sections"
      title="Sections"
      description="A section is a set of one or more learners who meet during a term."
  />

  <describe_action
      group="schooltool.course-sections" name="list" title="List"
      order="10"
      interface="schooltool.course.interfaces.ISectionContainer"
      permission="schooltool.view"
  />

  <describe_action
      group="schooltool.course-sections" name="create_delete" title="Create/Delete"
      order="20"
      interface="schooltool.course.interfaces.ISectionContainer"
      permission="schooltool.edit"
  />

  <describe_action
      group="schooltool.course-sections" name="view" title="View"
      order="30"
      interface="schooltool.course.interfaces.ISection"
      permission="schooltool.view"
  />

  <describe_action
      group="schooltool.course-sections" name="modify" title="Modify"
      order="40"
      interface="schooltool.course.interfaces.ISection"
      permission="schooltool.edit"
  />

  <describe_action
      group="schooltool.course-sections" name="view_calendar"
      title="View calendar"
      order="50"
      interface="schooltool.app.interfaces.ISchoolToolCalendar"
      permission="schooltool.view"
  />

  <describe_action
      group="schooltool.course-sections" name="change_calendar"
      title="Change calendar"
      order="60"
      interface="schooltool.app.interfaces.ISchoolToolCalendar"
      permission="schooltool.edit"
  />

  <!-- Parent crowds -->

  <zope:adapter
      trusted="yes"
      factory=".section.SectionCalendarViewers"
      provides="schooltool.app.interfaces.ICalendarParentCrowd"
      name="schooltool.view" />

  <zope:adapter
      trusted="yes"
      for=".interfaces.ISection"
      factory=".section.InstructorsCrowd"
      provides="schooltool.app.interfaces.ICalendarParentCrowd"
      name="schooltool.edit" />

  <switch_description
     group="schooltool.course-sections"
     crowd_factory="schooltool.app.security.CalendarViewersCrowd"
     use_crowd_factory=".section.SectionCalendarViewers"
  />

  <switch_description
     group="schooltool.course-sections"
     crowd_factory="schooltool.app.security.CalendarEditorsCrowd"
     use_crowd_factory=".section.InstructorsCrowd"
  />

</configure>
