2
# SchoolTool - common information systems platform for school administration
3
# Copyright (c) 2005 Shuttleworth Foundation
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Requirement Security
23
from zope.component import adapts
24
from zope.interface import implements
26
from schooltool.course.interfaces import ISection
27
from schooltool.course.section import LearnersCrowd
28
from schooltool.course.section import InstructorsCrowd
29
from schooltool.course.section import SectionCalendarSettingCrowd
30
from schooltool.requirement.interfaces import IRequirement
31
from schooltool.securitypolicy.crowds import ParentCrowd
32
from schooltool.securitypolicy.crowds import AggregateCrowd
33
from schooltool.app.security import LeaderCrowd
34
from schooltool.securitypolicy.crowds import EverybodyCrowd
35
from schooltool.securitypolicy.crowds import ParentCrowdTemplate
36
from schooltool.securitypolicy.interfaces import ICrowd
37
from schooltool.course.interfaces import ICourse
40
class IRequirementParentCrowd(ICrowd):
41
"""A crowd object that is used on a requirement's parent.
43
This is just a marker interface.
47
RequirementViewersCrowd = ParentCrowd(
48
IRequirementParentCrowd, 'schooltool.view')
51
RequirementEditorsCrowd = ParentCrowd(
52
IRequirementParentCrowd, 'schooltool.edit')
55
class RequirementRequirementEditorsCrowd(ParentCrowdTemplate):
56
"""People who can view subrequirements of a requirement.
58
Requirement editors crowd depends on the parent object, but if
59
that parent is a requirement we are retrieving permissions of it's
63
implements(IRequirementParentCrowd)
65
permission = 'schooltool.edit'
66
interface = IRequirementParentCrowd
69
class RequirementRequirementViewersCrowd(ParentCrowdTemplate):
70
"""People who can view subrequirements of a requirement.
72
Requirement viewers crowd depends on the parent object, but if
73
that parent is a requirement we are retrieving permissions of it's
77
implements(IRequirementParentCrowd)
79
permission = 'schooltool.view'
80
interface = IRequirementParentCrowd
83
class CourseRequirementEditorsCrowd(LeaderCrowd):
84
"""People who can edit requirements of a course"""
86
implements(IRequirementParentCrowd)
89
class CourseRequirementViewersCrowd(EverybodyCrowd):
90
"""People who can view requirements of a course"""
92
implements(IRequirementParentCrowd)
95
class SectionRequirementEditorsCrowd(InstructorsCrowd):
96
"""People who can edit requirements of a section"""
98
implements(IRequirementParentCrowd)
101
class SectionRequirementViewersCrowd(AggregateCrowd):
102
"""People who can view requirements of a course"""
104
implements(IRequirementParentCrowd)
106
def crowdFactories(self):
107
return [SectionCalendarSettingCrowd, InstructorsCrowd, LearnersCrowd]