Changeset 11840 for main/kofacustom.pcn


Ignore:
Timestamp:
14 Oct 2014, 10:28:24 (10 years ago)
Author:
Henrik Bettermann
Message:

Customize IFaculty and IDepartment.

Location:
main/kofacustom.pcn/trunk/src/kofacustom/pcn
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.pcn/trunk/src/kofacustom/pcn/applicants/browser.py

    r11832 r11840  
    2121from waeup.kofa.applicants.browser import (
    2222    ApplicantRegistrationPage, ApplicantsContainerPage)
     23from waeup.kofa.applicants.viewlets import (
     24    StudentCreateActionButton,
     25    ApplicantsRootCreateStudentsActionButton
     26    )
    2327from kofacustom.pcn.interfaces import MessageFactory as _
    2428
     29class StudentCreateActionButton(StudentCreateActionButton):
     30
     31    @property
     32    def target_url(self):
     33        """Get a URL to the target...
     34        """
     35        return
     36
     37class ApplicantsRootCreateStudentsActionButton(ApplicantsRootCreateStudentsActionButton):
     38
     39    @property
     40    def target_url(self):
     41        """Get a URL to the target...
     42        """
     43        return
  • main/kofacustom.pcn/trunk/src/kofacustom/pcn/browser/pages.py

    r11839 r11840  
    2020    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    2121    LoginPage, CertificatePage, CertificateManageFormPage, DepartmentPage,
    22     DepartmentManageFormPage, CertificateAddFormPage, DepartmentAddFormPage)
    23 from waeup.kofa.university.interfaces import IDepartment, ICertificate
     22    DepartmentManageFormPage, CertificateAddFormPage, DepartmentAddFormPage,
     23    FacultyManageFormPage, FacultyAddFormPage)
     24from waeup.kofa.university.interfaces import ICertificate
    2425from kofacustom.pcn.interfaces import (
    2526    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)
     27
     28from kofacustom.pcn.university.faculty import IDepartment, IFaculty
    2629
    2730grok.templatedir('templates')
     
    3639    """
    3740    form_fields = grok.AutoFields(ICustomSessionConfiguration)
     41
     42
     43class FacultyAddFormPage(FacultyAddFormPage):
     44    """ Page form to add a new faculty to a faculty container.
     45    """
     46    form_fields = grok.AutoFields(IFaculty)
     47
     48class FacultyManageFormPage(FacultyManageFormPage):
     49    """Manage the basic properties of a `Faculty` instance.
     50    """
     51    form_fields = grok.AutoFields(IFaculty).omit('code')
    3852
    3953class DepartmentPage(DepartmentPage):
  • main/kofacustom.pcn/trunk/src/kofacustom/pcn/university/faculty.py

    r11839 r11840  
    11import grok
    2 from waeup.kofa.university.interfaces import IDepartment, ICertificate
     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
    36from waeup.kofa.university.faculty import (
    47    Faculty, FacultyFactory)
     
    710from waeup.kofa.university.certificate import (
    811    Certificate, CertificateFactory)
     12from waeup.kofa.university.vocabularies import (
     13    course_levels,
     14    CourseSource,
     15    StudyModeSource,
     16    AppCatSource,
     17    InstTypeSource,
     18    SemesterSource,
     19    )
    920
     21
     22from waeup.kofa.interfaces import MessageFactory as _
     23
     24
     25class IFaculty(IKofaContainer):
     26    """Representation of a university faculty.
     27    """
     28
     29    code = schema.TextLine(
     30        title = _(u'Code'),
     31        default = u'NA',
     32        required = True,
     33        )
     34
     35    title = schema.TextLine(
     36        title = _(u'Name of faculty'),
     37        default = u'Unnamed',
     38        required = True,
     39        )
     40
     41    title_prefix = schema.Choice(
     42        title = _(u'Name prefix'),
     43        default = u'faculty',
     44        source = InstTypeSource(),
     45        required = True,
     46        )
     47
     48    address = schema.Text(
     49        title = _(u'Permanent Address'),
     50        required = False,
     51        )
     52
     53    email = schema.ASCIILine(
     54        title = _(u'Email'),
     55        required = False,
     56        constraint=validate_email,
     57        )
    1058
    1159class CustomFaculty(Faculty):
    1260    """A university faculty.
    1361    """
     62    grok.implements(IFaculty)
     63
    1464    local_roles = [
    1565        'waeup.local.DepartmentOfficer',
    1666        'waeup.local.DepartmentManager',
    1767        ]
     68
     69    def __init__(self,
     70                 title=u'Unnamed Faculty',
     71                 title_prefix=u'faculty',
     72                 address=None,
     73                 email=None,
     74                 code=u'NA', **kw):
     75        super(Faculty, self).__init__(**kw)
     76        self.title = title
     77        self.title_prefix = title_prefix
     78        self.code = code
     79        self.address = address
     80        self.email = email
    1881
    1982class CustomFacultyFactory(FacultyFactory):
     
    2790        return implementedBy(CustomFaculty)
    2891
     92class IDepartment(IKofaObject):
     93    """Representation of a department.
     94    """
     95    code = schema.TextLine(
     96        title = _(u'Code'),
     97        default = u'NA',
     98        required = True,
     99        )
     100
     101    title = schema.TextLine(
     102        title = _(u'Name of department'),
     103        default = u'Unnamed',
     104        required = True,
     105        )
     106
     107    title_prefix = schema.Choice(
     108        title = _(u'Name prefix'),
     109        source = InstTypeSource(),
     110        default = u'department',
     111        required = True,
     112        )
     113
     114    address = schema.Text(
     115        title = _(u'Permanent Address'),
     116        required = False,
     117        )
     118
     119    email = schema.ASCIILine(
     120        title = _(u'Email'),
     121        required = False,
     122        constraint=validate_email,
     123        )
     124
     125    certificates = Attribute("A container for certificates.")
     126
    29127class CustomDepartment(Department):
    30128    """A university department.
     
    37135        'waeup.local.DepartmentManager',
    38136        ]
     137
     138    def __init__(self,
     139                 title=u'Unnamed Department',
     140                 title_prefix=u'department',
     141                 address=None,
     142                 email=None,
     143                 code=u"NA", **kw):
     144        super(Department, self).__init__(**kw)
     145        self.title = title
     146        self.title_prefix = title_prefix
     147        self.code = code
     148        self.courses = CoursesContainer()
     149        self.courses.__parent__ = self
     150        self.courses.__name__ = 'courses'
     151        self.certificates = CertificatesContainer()
     152        self.certificates.__parent__ = self
     153        self.certificates.__name__ = 'certificates'
     154        self.score_editing_disabled = False
     155        self.address = address
     156        self.email = email
    39157
    40158class CustomDepartmentFactory(DepartmentFactory):
Note: See TracChangeset for help on using the changeset viewer.