Ignore:
Timestamp:
7 Feb 2017, 08:33:05 (8 years ago)
Author:
Henrik Bettermann
Message:

Add officer name fields do IDepartment and IFaculty. Plugins must be updated!

Location:
main/waeup.kofa/trunk/src/waeup/kofa/university
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r13212 r14511  
    6363                 title=u'Unnamed Department',
    6464                 title_prefix=u'department',
    65                  code=u"NA", **kw):
     65                 code=u"NA",
     66                 officer_1=None,
     67                 officer_2=None,
     68                 officer_3=None,
     69                 officer_4=None,
     70                 **kw):
    6671        super(Department, self).__init__(**kw)
    6772        self.title = title
    6873        self.title_prefix = title_prefix
     74        self.officer_1 = officer_1
     75        self.officer_2 = officer_2
     76        self.officer_3 = officer_3
     77        self.officer_4 = officer_4
    6978        self.code = code
    7079        self.courses = CoursesContainer()
  • main/waeup.kofa/trunk/src/waeup/kofa/university/export.py

    r13654 r14511  
    3232    grok.name('faculties')
    3333
    34     fields = ('code', 'title', 'title_prefix', 'users_with_local_roles')
     34    fields = ('code', 'title', 'title_prefix', 'users_with_local_roles',
     35              'officer_1', 'officer_2')
    3536
    3637    title = _(u'Faculties')
     
    7879
    7980    fields = ('code', 'faculty_code', 'title', 'title_prefix',
    80         'users_with_local_roles')
     81              'users_with_local_roles',
     82              'officer_1', 'officer_2','officer_3', 'officer_4')
    8183
    8284    title = _(u'Departments')
  • main/waeup.kofa/trunk/src/waeup/kofa/university/facultiescontainer.py

    r10279 r14511  
    6666    """
    6767    grok.implements(IKofaPluggable)
    68     grok.name('faculties')
     68    grok.name('academics')
    6969
    7070    def setup(self, site, name, logger):
  • main/waeup.kofa/trunk/src/waeup/kofa/university/faculty.py

    r12632 r14511  
    2424from zope.interface import implementedBy
    2525from zope.component import getUtility
    26 from waeup.kofa.interfaces import IKofaUtils
     26from zope.schema import getFields
     27from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable
    2728from waeup.kofa.utils.batching import VirtualExportJobContainer
    2829from waeup.kofa.university.interfaces import (
     
    6768                 title=u'Unnamed Faculty',
    6869                 title_prefix=u'faculty',
    69                  code=u'NA', **kw):
     70                 code=u'NA',
     71                 officer_1=None,
     72                 officer_2=None,
     73                 **kw):
    7074        super(Faculty, self).__init__(**kw)
    7175        self.title = title
    7276        self.title_prefix = title_prefix
    7377        self.code = code
     78        self.officer_1 = officer_1
     79        self.officer_2 = officer_2
    7480
    7581    def traverse(self, name):
     
    107113    def getInterfaces(self):
    108114        return implementedBy(Faculty)
     115
     116class FacultiesPlugin(grok.GlobalUtility):
     117    """A plugin that updates faculties.
     118    """
     119
     120    grok.implements(IKofaPluggable)
     121    grok.name('faculties')
     122
     123    deprecated_attributes = []
     124
     125    def setup(self, site, name, logger):
     126        return
     127
     128    def update(self, site, name, logger):
     129        items = getFields(IFaculty).items()
     130        for faculty in site['faculties'].values():
     131             # Add new attributes
     132            for i in items:
     133                if not hasattr(faculty,i[0]):
     134                    setattr(faculty,i[0],i[1].missing_value)
     135                    logger.info(
     136                        'FacultiesPlugin: %s attribute %s added.' % (
     137                        faculty.code,i[0]))
     138            # Remove deprecated attributes
     139            for i in self.deprecated_attributes:
     140                try:
     141                    delattr(faculty,i)
     142                    logger.info(
     143                        'FacultiesPlugin: %s attribute %s deleted.' % (
     144                        faculty.code,i))
     145                except AttributeError:
     146                    pass
     147        return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r13617 r14511  
    5656        )
    5757
     58    officer_1 = schema.TextLine(
     59        title = _(u'Faculty Officer 1'),
     60        default = u'',
     61        required = False,
     62        )
     63
     64    officer_2 = schema.TextLine(
     65        title = _(u'Faculty Officer 2'),
     66        default = u'',
     67        required = False,
     68        )
     69
    5870
    5971class IFacultiesContainer(IKofaContainer):
     
    93105        required = False,
    94106        default = False,
     107        )
     108
     109    officer_1 = schema.TextLine(
     110        title = _(u'Department Officer 1'),
     111        default = u'',
     112        required = False,
     113        )
     114
     115    officer_2 = schema.TextLine(
     116        title = _(u'Department Officer 2'),
     117        default = u'',
     118        required = False,
     119        )
     120
     121    officer_3 = schema.TextLine(
     122        title = _(u'Department Officer 3'),
     123        default = u'',
     124        required = False,
     125        )
     126
     127    officer_4 = schema.TextLine(
     128        title = _(u'Department Officer 4'),
     129        default = u'',
     130        required = False,
    95131        )
    96132
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_export.py

    r13654 r14511  
    6767        self.assertEqual(
    6868            result,
    69             'code,title,title_prefix,users_with_local_roles\r\n'
    70             'F1,Faculty of Cheese,faculty,[]\r\n'
     69            'code,title,title_prefix,users_with_local_roles,'
     70            'officer_1,officer_2\r\n'
     71            'F1,Faculty of Cheese,faculty,[],,\r\n'
    7172            )
    7273        return
     
    7980        self.assertEqual(
    8081            result,
    81             'code,title,title_prefix,users_with_local_roles\r\n'
    82             'F1,Faculty of Cheese,faculty,[]\r\n'
     82            'code,title,title_prefix,users_with_local_roles,'
     83            'officer_1,officer_2\r\n'
     84            'F1,Faculty of Cheese,faculty,[],,\r\n'
    8385            )
    8486        return
     
    9799        self.assertEqual(
    98100            result,
    99             'code,title,title_prefix,users_with_local_roles\r\n'
    100             'F1,Faculty of Cheese,faculty,[]\r\n'
    101             'F2,Centre of Onion,centre,[]\r\n'
     101            'code,title,title_prefix,users_with_local_roles,'
     102            'officer_1,officer_2\r\n'
     103            'F1,Faculty of Cheese,faculty,[],,\r\n'
     104            'F2,Centre of Onion,centre,[],,\r\n'
    102105            )
    103106        return
     
    115118        self.assertEqual(
    116119            result,
    117             'code,title,title_prefix,users_with_local_roles\r\n'
    118             'F1,Faculty of Cheese,faculty,[]\r\n'
    119             'F2,Centre of Onion,centre,[]\r\n'
     120            'code,title,title_prefix,users_with_local_roles,'
     121            'officer_1,officer_2\r\n'
     122            'F1,Faculty of Cheese,faculty,[],,\r\n'
     123            'F2,Centre of Onion,centre,[],,\r\n'
    120124            )
    121125        return
     
    136140        container.addFaculty(self.fac1)
    137141        container.addFaculty(self.fac2)
    138         self.dept1 = Department('Department of Cheddar', 'department', 'D1')
     142        self.dept1 = Department(
     143            'Department of Cheddar', 'department', 'D1', 'HoCheese')
    139144        self.dept2 = Department('Institue of Gouda', 'institute', 'D2')
    140145        self.dept3 = Department('Department of Rings', 'department', 'D3')
     
    170175        self.assertEqual(
    171176            result,
    172             'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
     177            'code,faculty_code,title,title_prefix,users_with_local_roles,'
     178            'officer_1,officer_2,officer_3,officer_4\r\n'
    173179            'D1,F1,Department of Cheddar,department,'
    174             '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
     180            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]",'
     181            'HoCheese,,,\r\n'
    175182            )
    176183        return
     
    182189        self.assertEqual(
    183190            result,
    184             'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
     191            'code,faculty_code,title,title_prefix,users_with_local_roles,'
     192            'officer_1,officer_2,officer_3,officer_4\r\n'
    185193            'D1,F1,Department of Cheddar,department,'
    186             '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
    187             'D2,F1,Institue of Gouda,institute,[]\r\n'
     194            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]",'
     195            'HoCheese,,,\r\n'
     196            'D2,F1,Institue of Gouda,institute,[],,,,\r\n'
    188197            )
    189198        return
     
    196205        self.assertEqual(
    197206            result,
    198             'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
     207            'code,faculty_code,title,title_prefix,users_with_local_roles,'
     208            'officer_1,officer_2,officer_3,officer_4\r\n'
    199209            'D1,F1,Department of Cheddar,department,'
    200             '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
    201             'D2,F1,Institue of Gouda,institute,[]\r\n'
    202             'D3,F2,Department of Rings,department,[]\r\n'
     210            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]",'
     211            'HoCheese,,,\r\n'
     212            'D2,F1,Institue of Gouda,institute,[],,,,\r\n'
     213            'D3,F2,Department of Rings,department,[],,,,\r\n'
    203214            )
    204215        return
     
    210221        self.assertEqual(
    211222            result,
    212             'code,faculty_code,title,title_prefix,users_with_local_roles\r\n'
     223            'code,faculty_code,title,title_prefix,users_with_local_roles,'
     224            'officer_1,officer_2,officer_3,officer_4\r\n'
    213225            'D1,F1,Department of Cheddar,department,'
    214             '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]"\r\n'
    215             'D2,F1,Institue of Gouda,institute,[]\r\n'
    216             'D3,F2,Department of Rings,department,[]\r\n'
     226            '"[{\'user_name\': u\'bob\', \'local_role\': u\'bobsrole\'}]",'
     227            'HoCheese,,,\r\n'
     228            'D2,F1,Institue of Gouda,institute,[],,,,\r\n'
     229            'D3,F2,Department of Rings,department,[],,,,\r\n'
    217230            )
    218231        return
Note: See TracChangeset for help on using the changeset viewer.