- Timestamp:
- 10 Sep 2012, 11:05:07 (12 years ago)
- Location:
- main/waeup.kofa/branches/uli-async-update
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-async-update
- Property svn:mergeinfo changed
-
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/university/export.py
r8301 r9169 19 19 """ 20 20 import grok 21 from zope.securitypolicy.interfaces import IPrincipalRoleMap 21 22 from waeup.kofa.interfaces import ICSVExporter 22 23 from waeup.kofa.interfaces import MessageFactory as _ … … 30 31 31 32 #: Fieldnames considered by this exporter 32 fields = ('code', 'title', 'title_prefix' )33 fields = ('code', 'title', 'title_prefix', 'users_with_local_roles') 33 34 34 35 #: The title under which this exporter will be displayed 35 36 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) 36 48 37 49 def export(self, faculties, filepath=None): … … 50 62 If `filepath` is ``None``, a raw string with CSV data is returned. 51 63 """ 52 writer, outfile = self.get_csv_writer(filepath)53 64 faculties = site.get('faculties', {}) 54 65 return self.export(faculties.values(), filepath) … … 61 72 62 73 #: 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') 64 76 65 77 #: The title under which this exporter will be displayed … … 77 89 78 90 def export_all(self, site, filepath=None): 79 """Export faculties in facultycontainerinto filepath as CSV data.91 """Export departments in faculty into filepath as CSV data. 80 92 81 93 If `filepath` is ``None``, a raw string with CSV data is returned. … … 97 109 #: Fieldnames considered by this exporter 98 110 fields = ('code', 'faculty_code', 'department_code', 'title', 'credits', 99 'passmark', 'semester' )111 'passmark', 'semester', 'users_with_local_roles') 100 112 101 113 #: The title under which this exporter will be displayed … … 105 117 """Hook for mangling values in derived classes 106 118 """ 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': 108 125 try: 109 126 value = context.__parent__.__parent__.__parent__.code … … 119 136 120 137 def export_all(self, site, filepath=None): 121 """Export faculties in facultycontainerinto filepath as CSV data.138 """Export courses into filepath as CSV data. 122 139 123 140 If `filepath` is ``None``, a raw string with CSV data is returned. … … 140 157 fields = ('code', 'faculty_code', 'department_code', 'title', 'study_mode', 141 158 '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') 143 161 144 162 #: The title under which this exporter will be displayed … … 146 164 147 165 def export_all(self, site, filepath=None): 148 """Export faculties in facultycontainerinto filepath as CSV data.166 """Export certificates into filepath as CSV data. 149 167 150 168 If `filepath` is ``None``, a raw string with CSV data is returned. … … 193 211 194 212 def export_all(self, site, filepath=None): 195 """Export faculties in facultycontainerinto filepath as CSV data.213 """Export certificate courses into filepath as CSV data. 196 214 197 215 If `filepath` is ``None``, a raw string with CSV data is returned.
Note: See TracChangeset for help on using the changeset viewer.