source: main/kofacustom.pcn/trunk/src/kofacustom/pcn/university/faculty.py @ 11890

Last change on this file since 11890 was 11841, checked in by Henrik Bettermann, 10 years ago

More adjustments.

File size: 4.7 KB
Line 
1import grok
2from zope import schema
3from zope.interface import Attribute, invariant, Invalid
4from waeup.kofa.interfaces import (IKofaObject, IKofaContainer, validate_email)
5from waeup.kofa.university.interfaces import ICertificate
6from waeup.kofa.university.certificatescontainer import CertificatesContainer
7from waeup.kofa.university.faculty import (
8    Faculty, FacultyFactory)
9from waeup.kofa.university.department import (
10    Department, DepartmentFactory)
11from waeup.kofa.university.certificate import (
12    Certificate, CertificateFactory)
13from waeup.kofa.university.vocabularies import (
14    course_levels,
15    CourseSource,
16    StudyModeSource,
17    AppCatSource,
18    InstTypeSource,
19    SemesterSource,
20    )
21
22
23from waeup.kofa.interfaces import MessageFactory as _
24
25
26class IFaculty(IKofaContainer):
27    """Representation of a university faculty.
28    """
29
30    code = schema.TextLine(
31        title = _(u'Code'),
32        default = u'NA',
33        required = True,
34        )
35
36    title = schema.TextLine(
37        title = _(u'Name of faculty'),
38        default = u'Unnamed',
39        required = True,
40        )
41
42    title_prefix = schema.Choice(
43        title = _(u'Name prefix'),
44        default = u'faculty',
45        source = InstTypeSource(),
46        required = True,
47        )
48
49    address = schema.Text(
50        title = _(u'Permanent Address'),
51        required = False,
52        )
53
54    email = schema.ASCIILine(
55        title = _(u'Email'),
56        required = False,
57        constraint=validate_email,
58        )
59
60class CustomFaculty(Faculty):
61    """A university faculty.
62    """
63    grok.implements(IFaculty)
64
65    local_roles = [
66        'waeup.local.DepartmentOfficer',
67        'waeup.local.DepartmentManager',
68        ]
69
70    def __init__(self,
71                 title=u'Unnamed Faculty',
72                 title_prefix=u'faculty',
73                 address=None,
74                 email=None,
75                 code=u'NA', **kw):
76        super(Faculty, self).__init__(**kw)
77        self.title = title
78        self.title_prefix = title_prefix
79        self.code = code
80        self.address = address
81        self.email = email
82
83class CustomFacultyFactory(FacultyFactory):
84    """A factory for faculty containers.
85    """
86
87    def __call__(self, *args, **kw):
88        return CustomFaculty()
89
90    def getInterfaces(self):
91        return implementedBy(CustomFaculty)
92
93class IDepartment(IKofaObject):
94    """Representation of a department.
95    """
96    code = schema.TextLine(
97        title = _(u'Code'),
98        default = u'NA',
99        required = True,
100        )
101
102    title = schema.TextLine(
103        title = _(u'Name of department'),
104        default = u'Unnamed',
105        required = True,
106        )
107
108    title_prefix = schema.Choice(
109        title = _(u'Name prefix'),
110        source = InstTypeSource(),
111        default = u'department',
112        required = True,
113        )
114
115    address = schema.Text(
116        title = _(u'Permanent Address'),
117        required = False,
118        )
119
120    email = schema.ASCIILine(
121        title = _(u'Email'),
122        required = False,
123        constraint=validate_email,
124        )
125
126    certificates = Attribute("A container for certificates.")
127
128class CustomDepartment(Department):
129    """A university department.
130    """
131    grok.implements(IDepartment)
132
133    local_roles = [
134        'waeup.local.ApplicationsManager',
135        'waeup.local.DepartmentOfficer',
136        'waeup.local.DepartmentManager',
137        ]
138
139    def __init__(self,
140                 title=u'Unnamed Department',
141                 title_prefix=u'department',
142                 address=None,
143                 email=None,
144                 code=u"NA", **kw):
145        super(Department, self).__init__(**kw)
146        self.title = title
147        self.title_prefix = title_prefix
148        self.code = code
149        self.certificates = CertificatesContainer()
150        self.certificates.__parent__ = self
151        self.certificates.__name__ = 'certificates'
152        self.score_editing_disabled = False
153        self.address = address
154        self.email = email
155
156class CustomDepartmentFactory(DepartmentFactory):
157    """A factory for department containers.
158    """
159
160    def __call__(self, *args, **kw):
161        return CustomDepartment(*args, **kw)
162
163    def getInterfaces(self):
164        """Get interfaces of objects provided by this factory.
165        """
166        return implementedBy(CustomDepartment)
167
168class CustomCertificate(Certificate):
169    """A certificate.
170    """
171    grok.implements(ICertificate)
172
173    local_roles = [
174        'waeup.local.DepartmentOfficer',
175        ]
176
177class CustomCertificateFactory(CertificateFactory):
178    """A factory for certificates.
179    """
180
181    def __call__(self, *args, **kw):
182        return CustomCertificate(*args, **kw)
183
184    def getInterfaces(self):
185        return implementedBy(CustomCertificate)
Note: See TracBrowser for help on using the repository browser.