- Timestamp:
- 17 Jun 2012, 06:42:20 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py
r8194 r8735 51 51 return self.__parent__ 52 52 53 def writeLogMessage(self, view, message): 54 return self.__parent__.writeLogMessage(view, message) 55 53 56 StudentAccommodation = attrs_to_fields(StudentAccommodation) 54 57 … … 68 71 def getStudent(self): 69 72 return self.__parent__.__parent__ 73 74 def writeLogMessage(self, view, message): 75 return self.__parent__.__parent__.writeLogMessage(view, message) 70 76 71 77 def getSessionString(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8688 r8735 62 62 from waeup.kofa.browser.resources import toggleall 63 63 from waeup.kofa.hostels.hostel import NOT_OCCUPIED 64 from waeup.kofa.utils.helpers import get_current_principal, to_timezone 65 66 def write_log_message(view, message): 67 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 68 view.context.getStudent().loggerInfo(ob_class, message) 69 return 70 71 # Save function used for save methods in pages 72 def msave(view, **data): 73 changed_fields = view.applyData(view.context, **data) 74 # Turn list of lists into single list 75 if changed_fields: 76 changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) 77 # Inform catalog if certificate has changed 78 # (applyData does this only for the context) 79 if 'certificate' in changed_fields: 80 notify(grok.ObjectModifiedEvent(view.context.getStudent())) 81 fields_string = ' + '.join(changed_fields) 82 view.flash(_('Form has been saved.')) 83 if fields_string: 84 write_log_message(view, 'saved: %s' % fields_string) 85 return 64 from waeup.kofa.utils.helpers import get_current_principal, to_timezone, msave 86 65 87 66 def emit_lock_message(view): … … 394 373 self.flash(_('Form has been saved.')) 395 374 if fields_string: 396 write_log_message(self, 'saved: % s' % fields_string)375 self.context.writeLogMessage(self, 'saved: % s' % fields_string) 397 376 return 398 377 … … 1030 1009 self.flash(_('Successfully removed: ${a}', 1031 1010 mapping = {'a': ', '.join(deleted)})) 1032 write_log_message(self,'removed: % s' % ', '.join(deleted)) 1011 self.context.writeLogMessage( 1012 self,'removed: % s' % ', '.join(deleted)) 1033 1013 self.redirect(self.url(self.context)) 1034 1014 return … … 1101 1081 success, msg, log = self.context.approveStudentPayment() 1102 1082 if log is not None: 1103 write_log_message(self,log)1083 self.context.writeLogMessage(self,log) 1104 1084 self.flash(msg) 1105 1085 return … … 1202 1182 self.flash(_('Successfully removed: ${a}', 1203 1183 mapping = {'a':', '.join(deleted)})) 1204 write_log_message(self,'removed: % s' % ', '.join(deleted)) 1184 self.context.writeLogMessage( 1185 self,'removed: % s' % ', '.join(deleted)) 1205 1186 self.redirect(self.url(self.context)) 1206 1187 return … … 1498 1479 if not errors: 1499 1480 IUserAccount(self.context).setPassword(password) 1500 write_log_message(self, 'saved: password')1481 self.context.writeLogMessage(self, 'saved: password') 1501 1482 self.flash(_('Password changed.')) 1502 1483 else: -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r8621 r8735 129 129 130 130 class IStudentNavigation(IKofaObject): 131 """Interface needed for student navigation .131 """Interface needed for student navigation, logging, etc. 132 132 133 133 """ 134 134 def getStudent(): 135 135 """Return student object. 136 137 """ 138 139 def writeLogMessage(view, message): 140 """Write a view specific log message into students.log. 136 141 137 142 """ … … 152 157 display_fullname = Attribute('The fullname of an applicant') 153 158 154 def loggerInfo(ob_class, comment):155 """Adds an INFO message to the log file.156 157 """158 159 159 student_id = schema.TextLine( 160 160 title = _(u'Student Id'), … … 383 383 def addCourseTicket(courseticket): 384 384 """Add a course ticket object. 385 """386 387 def getStudent():388 """Return student389 385 """ 390 386 -
main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py
r8732 r8735 43 43 return self.__parent__ 44 44 45 def writeLogMessage(self, view, message): 46 return self.__parent__.writeLogMessage(view, message) 47 45 48 StudentPaymentsContainer = attrs_to_fields(StudentPaymentsContainer) 46 49 … … 60 63 except AttributeError: 61 64 return None 65 66 def writeLogMessage(self, view, message): 67 return self.__parent__.__parent__.writeLogMessage(view, message) 62 68 63 69 def _createActivationCodes(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r8481 r8735 61 61 return 62 62 63 def loggerInfo(self, ob_class, comment=None):64 target = self.__name__65 return grok.getSite()['students'].logger_info(ob_class,target,comment)63 def writeLogMessage(self, view, message): 64 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 65 return self.__parent__.logger_info(ob_class,self.__name__,comment=None) 66 66 67 67 @property … … 139 139 self.get('studycourse', None), 'is_postgrad', False) 140 140 return is_postgrad 141 141 142 142 143 # Set all attributes of Student required in IStudent as field -
main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py
r8483 r8735 42 42 def getStudent(self): 43 43 return self.__parent__ 44 45 def writeLogMessage(self, view, message): 46 return self.__parent__.writeLogMessage(view, message) 44 47 45 48 @property -
main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py
r8494 r8735 43 43 def getStudent(self): 44 44 return getattr(getattr(self, '__parent__', None), '__parent__', None) 45 46 def writeLogMessage(self, view, message): 47 return self.__parent__.__parent__.writeLogMessage(view, message) 45 48 46 49 @property … … 107 110 return None 108 111 112 def writeLogMessage(self, view, message): 113 return self.__parent__.__parent__.__parent__.writeLogMessage(view, message) 114 109 115 def getLevel(self): 110 116 """Returns the id of the level the ticket has been added to. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py
r8467 r8735 36 36 from waeup.kofa.students.interfaces import ( 37 37 IStudent, IStudentStudyCourse, IStudentPaymentsContainer, 38 IStudentAccommodation, IStudentStudyLevel, ICourseTicket, IBedTicket) 38 IStudentAccommodation, IStudentStudyLevel, ICourseTicket, IBedTicket, 39 IStudentNavigation) 39 40 from waeup.kofa.students.tests.test_batching import StudentImportExportSetup 40 41 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase … … 86 87 def test_interfaces(self): 87 88 verify.verifyClass(IStudent, Student) 89 verify.verifyClass(IStudentNavigation, Student) 88 90 verify.verifyObject(IStudent, self.student) 91 verify.verifyObject(IStudentNavigation, self.student) 92 89 93 verify.verifyClass(IStudentStudyCourse, StudentStudyCourse) 94 verify.verifyClass(IStudentNavigation, StudentStudyCourse) 90 95 verify.verifyObject(IStudentStudyCourse, self.studycourse) 96 verify.verifyObject(IStudentNavigation, self.studycourse) 97 98 verify.verifyClass(IStudentStudyLevel, StudentStudyLevel) 99 verify.verifyClass(IStudentNavigation, StudentStudyLevel) 91 100 verify.verifyObject(IStudentStudyLevel, self.studylevel) 101 verify.verifyObject(IStudentNavigation, self.studylevel) 102 103 verify.verifyClass(ICourseTicket, CourseTicket) 104 verify.verifyClass(IStudentNavigation, CourseTicket) 92 105 verify.verifyObject(ICourseTicket, self.courseticket) 106 verify.verifyObject(IStudentNavigation, self.courseticket) 107 93 108 verify.verifyClass(IStudentPaymentsContainer, StudentPaymentsContainer) 109 verify.verifyClass(IStudentNavigation, StudentPaymentsContainer) 94 110 verify.verifyObject(IStudentPaymentsContainer, self.payments) 111 verify.verifyObject(IStudentNavigation, self.payments) 112 95 113 verify.verifyClass(IStudentAccommodation, StudentAccommodation) 114 verify.verifyClass(IStudentNavigation, StudentAccommodation) 96 115 verify.verifyObject(IStudentAccommodation, self.accommodation) 116 verify.verifyObject(IStudentNavigation, self.accommodation) 117 97 118 verify.verifyClass(IBedTicket, BedTicket) 119 verify.verifyClass(IStudentNavigation, BedTicket) 98 120 verify.verifyObject(IBedTicket, self.bedticket) 121 verify.verifyObject(IStudentNavigation, self.bedticket) 99 122 return 100 123 -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r8476 r8735 35 35 VALIDATED) 36 36 from waeup.kofa.students.browser import ( 37 StudentClearanceManageFormPage, write_log_message,37 StudentClearanceManageFormPage, 38 38 StudentBaseManageFormPage, StudentFilesUploadPage, 39 39 ExportPDFClearanceSlipPage, StudentsContainerPage, … … 568 568 store = getUtility(IExtFileStore) 569 569 store.deleteFileByContext(context, attr=download_name) 570 write_log_message(view, 'deleted: %s' % download_name)570 context.writeLogMessage(view, 'deleted: %s' % download_name) 571 571 view.flash(_('${a} deleted.', mapping = {'a':download_name})) 572 572 return … … 607 607 file_id = IFileStoreNameChooser(context).chooseName(attr=download_name) 608 608 store.createFile(file_id, upload) 609 write_log_message(view, 'uploaded: %s (%s)' % (609 context.writeLogMessage(view, 'uploaded: %s (%s)' % ( 610 610 download_name,upload.filename)) 611 611 view.flash(_('File ${a} uploaded.', mapping = {'a':download_name})) -
main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py
r8310 r8735 151 151 studycourse.certificate = None 152 152 notify(grok.ObjectModifiedEvent(student)) 153 student.loggerInfo('ObjectRemovedEvent', 'removed: certificate') 153 student.__parent__.logger_info( 154 'ObjectRemovedEvent',student.__name__,'removed: certificate') 154 155 return 155 156 -
main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py
r8633 r8735 38 38 from zope.security.management import getInteraction 39 39 from zope.pluggableauth.interfaces import IAuthenticatorPlugin 40 from waeup.kofa.interfaces import MessageFactory as _ 40 41 41 42 BUFSIZE = 8 * 1024 … … 682 683 writer.writerow(row) 683 684 return tmp_path 685 686 # Save function used for save methods in pages 687 def msave(view, **data): 688 changed_fields = view.applyData(view.context, **data) 689 # Turn list of lists into single list 690 if changed_fields: 691 changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) 692 # Inform catalog if certificate has changed 693 # (applyData does this only for the context) 694 if 'certificate' in changed_fields: 695 notify(grok.ObjectModifiedEvent(view.context.getStudent())) 696 fields_string = ' + '.join(changed_fields) 697 view.flash(_('Form has been saved.')) 698 if fields_string: 699 view.context.writeLogMessage(view, 'saved: %s' % fields_string) 700 return
Note: See TracChangeset for help on using the changeset viewer.