~ubuntu-branches/ubuntu/natty/schooltool.gradebook/natty

« back to all changes in this revision

Viewing changes to src/schooltool/requirement/security.py

  • Committer: Bazaar Package Importer
  • Author(s): Gediminas Paulauskas
  • Date: 2011-02-24 16:53:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110224165353-hi69ckyal3b8dyns
Tags: upstream-0.9.0~a1
ImportĀ upstreamĀ versionĀ 0.9.0~a1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# SchoolTool - common information systems platform for school administration
 
3
# Copyright (c) 2005 Shuttleworth Foundation
 
4
#
 
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.
 
9
#
 
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.
 
14
#
 
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
 
18
#
 
19
"""Requirement Security
 
20
 
 
21
$Id$
 
22
"""
 
23
from zope.component import adapts
 
24
from zope.interface import implements
 
25
 
 
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
 
38
 
 
39
 
 
40
class IRequirementParentCrowd(ICrowd):
 
41
    """A crowd object that is used on a requirement's parent.
 
42
 
 
43
    This is just a marker interface.
 
44
    """
 
45
 
 
46
 
 
47
RequirementViewersCrowd = ParentCrowd(
 
48
    IRequirementParentCrowd, 'schooltool.view')
 
49
 
 
50
 
 
51
RequirementEditorsCrowd = ParentCrowd(
 
52
    IRequirementParentCrowd, 'schooltool.edit')
 
53
 
 
54
 
 
55
class RequirementRequirementEditorsCrowd(ParentCrowdTemplate):
 
56
    """People who can view subrequirements of a requirement.
 
57
 
 
58
    Requirement editors crowd depends on the parent object, but if
 
59
    that parent is a requirement we are retrieving permissions of it's
 
60
    parent.
 
61
    """
 
62
    adapts(IRequirement)
 
63
    implements(IRequirementParentCrowd)
 
64
 
 
65
    permission = 'schooltool.edit'
 
66
    interface = IRequirementParentCrowd
 
67
 
 
68
 
 
69
class RequirementRequirementViewersCrowd(ParentCrowdTemplate):
 
70
    """People who can view subrequirements of a requirement.
 
71
 
 
72
    Requirement viewers crowd depends on the parent object, but if
 
73
    that parent is a requirement we are retrieving permissions of it's
 
74
    parent.
 
75
    """
 
76
    adapts(IRequirement)
 
77
    implements(IRequirementParentCrowd)
 
78
 
 
79
    permission = 'schooltool.view'
 
80
    interface = IRequirementParentCrowd
 
81
 
 
82
 
 
83
class CourseRequirementEditorsCrowd(LeaderCrowd):
 
84
    """People who can edit requirements of a course"""
 
85
    adapts(ICourse)
 
86
    implements(IRequirementParentCrowd)
 
87
 
 
88
 
 
89
class CourseRequirementViewersCrowd(EverybodyCrowd):
 
90
    """People who can view requirements of a course"""
 
91
    adapts(ICourse)
 
92
    implements(IRequirementParentCrowd)
 
93
 
 
94
 
 
95
class SectionRequirementEditorsCrowd(InstructorsCrowd):
 
96
    """People who can edit requirements of a section"""
 
97
    adapts(ISection)
 
98
    implements(IRequirementParentCrowd)
 
99
 
 
100
 
 
101
class SectionRequirementViewersCrowd(AggregateCrowd):
 
102
    """People who can view requirements of a course"""
 
103
    adapts(ISection)
 
104
    implements(IRequirementParentCrowd)
 
105
 
 
106
    def crowdFactories(self):
 
107
        return [SectionCalendarSettingCrowd, InstructorsCrowd, LearnersCrowd]