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

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

Repair package. Hopefully we'll never need this package.

File size: 4.7 KB
RevLine 
[11839]1import grok
[11840]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
[11841]6from waeup.kofa.university.certificatescontainer import CertificatesContainer
[11839]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)
[11840]13from waeup.kofa.university.vocabularies import (
14    course_levels,
15    CourseSource,
16    StudyModeSource,
17    AppCatSource,
18    InstTypeSource,
19    SemesterSource,
20    )
[11839]21
22
[11840]23from waeup.kofa.interfaces import MessageFactory as _
24
25
[12234]26class ICustomFaculty(IKofaContainer):
[11840]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
[11839]60class CustomFaculty(Faculty):
61    """A university faculty.
62    """
[12234]63    grok.implements(ICustomFaculty)
[11840]64
[11839]65    local_roles = [
66        'waeup.local.DepartmentOfficer',
67        'waeup.local.DepartmentManager',
68        ]
69
[11840]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
[11839]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
[12234]93class ICustomDepartment(IKofaObject):
[11840]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
[12234]128
[11839]129class CustomDepartment(Department):
130    """A university department.
131    """
[12234]132    grok.implements(ICustomDepartment)
[11839]133
134    local_roles = [
135        'waeup.local.ApplicationsManager',
136        'waeup.local.DepartmentOfficer',
137        'waeup.local.DepartmentManager',
138        ]
139
[11840]140    def __init__(self,
141                 title=u'Unnamed Department',
142                 title_prefix=u'department',
143                 address=None,
144                 email=None,
145                 code=u"NA", **kw):
146        super(Department, self).__init__(**kw)
147        self.title = title
148        self.title_prefix = title_prefix
149        self.code = code
150        self.certificates = CertificatesContainer()
151        self.certificates.__parent__ = self
152        self.certificates.__name__ = 'certificates'
153        self.score_editing_disabled = False
154        self.address = address
155        self.email = email
156
[11839]157class CustomDepartmentFactory(DepartmentFactory):
158    """A factory for department containers.
159    """
160
161    def __call__(self, *args, **kw):
162        return CustomDepartment(*args, **kw)
163
164    def getInterfaces(self):
165        """Get interfaces of objects provided by this factory.
166        """
167        return implementedBy(CustomDepartment)
168
169class CustomCertificate(Certificate):
170    """A certificate.
171    """
172    grok.implements(ICertificate)
173
174    local_roles = [
175        'waeup.local.DepartmentOfficer',
176        ]
177
178class CustomCertificateFactory(CertificateFactory):
179    """A factory for certificates.
180    """
181
182    def __call__(self, *args, **kw):
183        return CustomCertificate(*args, **kw)
184
185    def getInterfaces(self):
[12234]186        return implementedBy(CustomCertificate)
Note: See TracBrowser for help on using the repository browser.