Ignore:
Timestamp:
10 Sep 2012, 11:05:07 (12 years ago)
Author:
uli
Message:

Merge changes from trunk, r8786-HEAD

Location:
main/waeup.kofa/branches/uli-async-update
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-async-update

  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/university/export.py

    r8301 r9169  
    1919"""
    2020import grok
     21from zope.securitypolicy.interfaces import IPrincipalRoleMap
    2122from waeup.kofa.interfaces import ICSVExporter
    2223from waeup.kofa.interfaces import MessageFactory as _
     
    3031
    3132    #: Fieldnames considered by this exporter
    32     fields = ('code', 'title', 'title_prefix')
     33    fields = ('code', 'title', 'title_prefix', 'users_with_local_roles')
    3334
    3435    #: The title under which this exporter will be displayed
    3536    title = _(u'Faculties')
     37
     38    def mangle_value(self, value, name, context=None):
     39        """Hook for mangling values in derived classes
     40        """
     41        if name == 'users_with_local_roles':
     42            value = []
     43            role_map = IPrincipalRoleMap(context)
     44            for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
     45                value.append({'user_name':user_name,'local_role':local_role})
     46        return super(FacultyExporter, self).mangle_value(
     47            value, name, context)
    3648
    3749    def export(self, faculties, filepath=None):
     
    5062        If `filepath` is ``None``, a raw string with CSV data is returned.
    5163        """
    52         writer, outfile = self.get_csv_writer(filepath)
    5364        faculties = site.get('faculties', {})
    5465        return self.export(faculties.values(), filepath)
     
    6172
    6273    #: Fieldnames considered by this exporter
    63     fields = ('code', 'faculty_code', 'title', 'title_prefix')
     74    fields = ('code', 'faculty_code', 'title', 'title_prefix',
     75        'users_with_local_roles')
    6476
    6577    #: The title under which this exporter will be displayed
     
    7789
    7890    def export_all(self, site, filepath=None):
    79         """Export faculties in facultycontainer into filepath as CSV data.
     91        """Export departments in faculty into filepath as CSV data.
    8092
    8193        If `filepath` is ``None``, a raw string with CSV data is returned.
     
    97109    #: Fieldnames considered by this exporter
    98110    fields = ('code', 'faculty_code', 'department_code', 'title', 'credits',
    99               'passmark', 'semester')
     111              'passmark', 'semester', 'users_with_local_roles')
    100112
    101113    #: The title under which this exporter will be displayed
     
    105117        """Hook for mangling values in derived classes
    106118        """
    107         if name == 'faculty_code':
     119        if name == 'users_with_local_roles':
     120            value = []
     121            role_map = IPrincipalRoleMap(context)
     122            for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
     123                value.append({'user_name':user_name,'local_role':local_role})
     124        elif name == 'faculty_code':
    108125            try:
    109126                value = context.__parent__.__parent__.__parent__.code
     
    119136
    120137    def export_all(self, site, filepath=None):
    121         """Export faculties in facultycontainer into filepath as CSV data.
     138        """Export courses into filepath as CSV data.
    122139
    123140        If `filepath` is ``None``, a raw string with CSV data is returned.
     
    140157    fields = ('code', 'faculty_code', 'department_code', 'title', 'study_mode',
    141158              'start_level', 'end_level', 'application_category',
    142               'school_fee_1', 'school_fee_2')
     159              'school_fee_1', 'school_fee_2', 'school_fee_3', 'school_fee_4',
     160              'users_with_local_roles')
    143161
    144162    #: The title under which this exporter will be displayed
     
    146164
    147165    def export_all(self, site, filepath=None):
    148         """Export faculties in facultycontainer into filepath as CSV data.
     166        """Export certificates into filepath as CSV data.
    149167
    150168        If `filepath` is ``None``, a raw string with CSV data is returned.
     
    193211
    194212    def export_all(self, site, filepath=None):
    195         """Export faculties in facultycontainer into filepath as CSV data.
     213        """Export certificate courses into filepath as CSV data.
    196214
    197215        If `filepath` is ``None``, a raw string with CSV data is returned.
Note: See TracChangeset for help on using the changeset viewer.