Changeset 12861 for main/waeup.kofa/trunk/src
- Timestamp:
- 17 Apr 2015, 14:43:42 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py
r12859 r12861 64 64 65 65 class ApplicantExporter(grok.GlobalUtility, ExporterBase): 66 """The Applicant Exporter exports a ll application records (= applicants)66 """The Applicant Exporter exports application records (= applicants) 67 67 stored in the database. In contrast to the exporters in the academics 68 68 section this exporter does not iterate over the items of containers 69 but searches the Applicants Catalog instead. 69 but searches the :class:`ApplicantsCatalog` instead. 70 71 The exporter exports all applicants if started in the Data Center 72 which means in the context of the `DataCenter` object. The exporter can also 73 be started 'locally' which means in the context of an `ApplicantsContainer` 74 container. Then the :meth:`export_filtered()` instead of the 75 :meth:`export_all()` method is applied which searches for applicants 76 in the respective container. 70 77 """ 71 78 grok.implements(ICSVExporter) … … 98 105 def export(self, applicants, filepath=None): 99 106 """Export `applicants`, an iterable, as CSV file. 100 101 107 If `filepath` is ``None``, a raw string with CSV data is returned. 102 108 """ … … 107 113 108 114 def export_all(self, site, filepath=None): 109 """Export applicants into filepath as CSV data. 110 115 """Export all applicants into filepath as CSV data. 111 116 If `filepath` is ``None``, a raw string with CSV data is returned. 112 117 """ … … 122 127 123 128 def export_filtered(self, site, filepath=None, **kw): 124 """Export applicants in container. 125 129 """Export filtered applicants in container denoted by keywords (`kw`). 126 130 If `filepath` is ``None``, a raw string with CSV data should 127 131 be returned. -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r12568 r12861 56 56 def get_tickets(students, **kw): 57 57 """Get course tickets of `students`. 58 59 58 If code is passed through, filter course tickets 60 59 which belong to this course code and meets level … … 89 88 def get_payments(students, paid=False, **kw): 90 89 """Get all payments of `students` within given payment_date period. 91 92 90 """ 93 91 date_format = '%d/%m/%Y' … … 146 144 class StudentExporterBase(ExporterBase): 147 145 """Exporter for students or related objects. 148 149 146 This is a baseclass. 150 147 """ … … 158 155 def get_filtered(self, site, **kw): 159 156 """Get students from a catalog filtered by keywords. 160 161 157 students_catalog is the default catalog. The keys must be valid 162 158 catalog index names. … … 192 188 def get_selected(self, site, selected): 193 189 """Get set of selected students. 194 195 190 Returns a simple empty list or a list with `Student` 196 191 objects. … … 206 201 def export(self, values, filepath=None): 207 202 """Export `values`, an iterable, as CSV file. 208 209 203 If `filepath` is ``None``, a raw string with CSV data is returned. 210 204 """ … … 216 210 def export_all(self, site, filepath=None): 217 211 """Export students into filepath as CSV data. 218 219 212 If `filepath` is ``None``, a raw string with CSV data is returned. 220 213 """ … … 226 219 def export_filtered(self, site, filepath=None, **kw): 227 220 """Export items denoted by `kw`. 228 229 221 If `filepath` is ``None``, a raw string with CSV data should 230 222 be returned. … … 242 234 243 235 class StudentExporter(grok.GlobalUtility, StudentExporterBase): 244 """Exporter for Students. 236 """The Student Exporter first filters the set of students by searching the 237 students catalog. Then it exports student base data of this set of students. 245 238 """ 246 239 grok.name('students') 247 240 248 #: Fieldnames considered by this exporter249 241 fields = tuple(sorted(iface_names(IStudent))) + ( 250 242 'password', 'state', 'history', 'certcode', 'is_postgrad', 251 243 'current_level', 'current_session') 252 253 #: The title under which this exporter will be displayed254 244 title = _(u'Students') 255 245 256 246 def mangle_value(self, value, name, context=None): 247 """The mangler prepares the history messages and adds a hash symbol at 248 the end of the phone number to avoid annoying automatic number 249 transformation by Excel or Calc.""" 257 250 if name == 'history': 258 251 value = value.messages … … 267 260 268 261 class StudentStudyCourseExporter(grok.GlobalUtility, StudentExporterBase): 269 """Exporter for StudentStudyCourses. 262 """The Student Study Course Exporter first filters the set of students 263 by searching the students catalog. Then it exports the data of the current 264 study course container of each student from this set. It does 265 not export their content. 270 266 """ 271 267 grok.name('studentstudycourses') 272 268 273 #: Fieldnames considered by this exporter274 269 fields = tuple(sorted(iface_names(IStudentStudyCourse))) + ('student_id',) 275 276 #: The title under which this exporter will be displayed277 270 title = _(u'Student Study Courses') 278 271 … … 281 274 282 275 def mangle_value(self, value, name, context=None): 283 """T reat location values special.276 """The mangler determines the certificate code and the student id. 284 277 """ 285 278 if name == 'certificate' and value is not None: … … 295 288 296 289 class StudentStudyLevelExporter(grok.GlobalUtility, StudentExporterBase): 297 """Exporter for StudentStudyLevels. 290 """The Student Study Level Exporter first filters the set of students 291 by searching the students catalog. Then it exports the data of the student's 292 study level containers but not their content (course tickets). 293 The exporter iterates over all objects in the students' ``studycourse`` 294 containers. 298 295 """ 299 296 grok.name('studentstudylevels') 300 297 301 #: Fieldnames considered by this exporter302 298 fields = tuple(sorted(iface_names( 303 299 IStudentStudyLevel) + ['level'])) + ( 304 300 'student_id', 'number_of_tickets','certcode') 305 306 #: The title under which this exporter will be displayed307 301 title = _(u'Student Study Levels') 308 302 … … 311 305 312 306 def mangle_value(self, value, name, context=None): 313 """T reat location values special.307 """The mangler determines the student id, nothing else. 314 308 """ 315 309 if name == 'student_id' and context is not None: … … 321 315 322 316 class CourseTicketExporter(grok.GlobalUtility, StudentExporterBase): 323 """Exporter for CourseTickets. 317 """The Course Ticket Exporter exports course tickets. Usually, 318 the exporter first filters the set of students by searching the 319 students catalog. Then it collects and iterates over all ``studylevel`` 320 containers of the filtered student set and finally 321 iterates over all items inside these containers. 322 323 If the course code is passed through, the exporter uses a different 324 catalog. It searches for students in the course tickets catalog and 325 exports those course tickets which belong to the given course code and 326 also meet level and level_session passed through at the same time. 327 This happens if the exporter is called at course level in the academics 328 section. 324 329 """ 325 330 grok.name('coursetickets') 326 331 327 #: Fieldnames considered by this exporter328 332 fields = tuple(sorted(iface_names(ICourseTicket) + 329 333 ['level', 'code', 'level_session'])) + ('student_id', 330 334 'certcode', 'display_fullname') 331 332 #: The title under which this exporter will be displayed333 335 title = _(u'Course Tickets') 334 336 … … 337 339 338 340 def mangle_value(self, value, name, context=None): 339 """T reat location values special.341 """The mangler determines the student's id and fullname. 340 342 """ 341 343 if context is not None: … … 343 345 if name in ('student_id', 'display_fullname') and student is not None: 344 346 value = getattr(student, name, None) 345 #if name == 'level':346 # value = getattr(context, 'level', lambda: None)347 #if name == 'level_session':348 # value = getattr(context, 'level_session', lambda: None)349 347 return super( 350 348 CourseTicketExporter, self).mangle_value( -
main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py
r12857 r12861 493 493 def close_outfile(self, filepath, outfile): 494 494 """Close outfile. 495 496 495 If filepath is None, the contents of outfile is returned. 497 496 """ … … 504 503 def get_filtered(self, site, **kw): 505 504 """Get datasets to export filtered by keyword arguments. 506 507 505 Returns an iterable. 508 506 """ … … 512 510 """Get datasets to export for selected items 513 511 specified by a list of identifiers. 514 515 512 Returns an iterable. 516 513 """ … … 519 516 def export(self, iterable, filepath=None): 520 517 """Export `iterable` as CSV file. 521 522 518 If `filepath` is ``None``, a raw string with CSV data should 523 519 be returned. … … 528 524 """Export all appropriate objects in `site` into `filepath` as 529 525 CSV data. 530 531 526 If `filepath` is ``None``, a raw string with CSV data should 532 527 be returned. … … 535 530 536 531 def export_filtered(self, site, filepath=None, **kw): 537 """Export items denoted by `args` and `kw`. 538 532 """Export items denoted by `kw`. 539 533 If `filepath` is ``None``, a raw string with CSV data should 540 534 be returned. … … 546 540 """Export those items specified by a list of identifiers 547 541 called `selected`. 548 549 542 If `filepath` is ``None``, a raw string with CSV data should 550 543 be returned.
Note: See TracChangeset for help on using the changeset viewer.