- Timestamp:
- 13 Nov 2014, 13:21:59 (10 years ago)
- Location:
- main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils/batching.py
r11849 r11947 338 338 obj = self.callFactory() 339 339 # Override all values in row, also 340 # student_ids and applicant_ids which have been340 # customer ids which have been 341 341 # generated in the respective __init__ methods before. 342 342 self.updateEntry(obj, row, site, base) -
main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils/browser.py
r9127 r11947 26 26 27 27 from waeup.kofa.interfaces import IUniversity 28 29 def replaceStudentMessages(old, new):30 students = grok.getSite()['students']31 for student in students.values():32 history = IObjectHistory(student)33 history.modifyMessages(old, new)34 return35 36 def replaceApplicantMessages(old, new):37 applicants = grok.getSite()['applicants']38 for container in applicants.values():39 for applicant in container.values():40 history = IObjectHistory(applicant)41 history.modifyMessages(old, new)42 return43 44 def removeStudentMessage(student_id, number):45 students = grok.getSite()['students']46 student = students.get(student_id, None)47 if student:48 history = IObjectHistory(student)49 success, text = history.removeMessage(number)50 return success, text51 52 def removeApplicantMessage(applicant_id, number):53 applicants = grok.getSite()['applicants']54 try:55 container, application_number = applicant_id.split('_')56 except:57 return False, 'applicant_id is wrong'58 container = applicants.get(container, None)59 if not container:60 return False, 'No such container'61 applicant = container.get(application_number, None)62 if applicant is None:63 return False, 'No such applicant'64 history = IObjectHistory(applicant)65 success, text = history.removeMessage(number)66 return success, text67 28 68 29 class ReindexPage(UtilityView, grok.View): … … 95 56 self.redirect(self.url(self.context, '@@index')) 96 57 return 97 98 class ModifyAllStudentHistory(UtilityView, grok.View):99 """ View to modify all student histories.100 101 """102 grok.context(IUniversity)103 grok.name('modify_student_history')104 grok.require('waeup.managePortal')105 106 def update(self,old=None, new=None):107 if None in (old, new):108 self.flash('Syntax: /modify_student_history?old=[old string]&new=[new string]')109 return110 replaceStudentMessages(old, new)111 self.context.logger.info(112 "'%s' replaced by '%s' in all student histories." % (old, new))113 self.flash('Finished')114 return115 116 def render(self):117 self.redirect(self.url(self.context, '@@index'))118 return119 120 class RemoveStudentHistoryMessage(UtilityView, grok.View):121 """ View to remove a single student history entry.122 123 """124 grok.context(IUniversity)125 grok.name('remove_student_history_message')126 grok.require('waeup.managePortal')127 128 def update(self,student_id=None, number=None):129 if None in (student_id, number):130 self.flash('Syntax: /remove_student_history_message?student_id=[id]&number=[line number, starting with 0]')131 return132 try:133 number=int(number)134 except:135 self.flash('Error')136 return137 success, text = removeStudentMessage(student_id, number)138 if not success:139 self.flash('Error: %s' % text)140 return141 self.context.logger.info(142 "line '%s' removed in %s history" % (text, student_id))143 self.flash('Finished')144 return145 146 def render(self):147 self.redirect(self.url(self.context, '@@index'))148 return149 150 class ModifyAllApplicantHistory(UtilityView, grok.View):151 """ View to modify all student histories.152 153 """154 grok.context(IUniversity)155 grok.name('modify_applicant_history')156 grok.require('waeup.managePortal')157 158 def update(self,old=None, new=None):159 if None in (old, new):160 self.flash('Syntax: /modify_applicant_history?old=[old string]&new=[new string]')161 return162 replaceApplicantMessages(old, new)163 self.context.logger.info(164 "'%s' replaced by '%s' in all applicant histories." % (old, new))165 self.flash('Finished')166 return167 168 def render(self):169 self.redirect(self.url(self.context, '@@index'))170 return171 172 class RemoveApplicantHistoryMessage(UtilityView, grok.View):173 """ View to remove a single applicant history entry.174 175 """176 grok.context(IUniversity)177 grok.name('remove_applicant_history_message')178 grok.require('waeup.managePortal')179 180 def update(self,applicant_id=None, number=None):181 if None in (applicant_id, number):182 self.flash('Syntax: /remove_applicant_history_message?applicant_id=[id]&number=[line number, starting with 0]')183 return184 try:185 number=int(number)186 except:187 self.flash('Error')188 return189 success, text = removeApplicantMessage(applicant_id, number)190 if not success:191 self.flash('Error: %s' % text)192 return193 self.context.logger.info(194 "line '%s' removed in %s history" % (text, applicant_id))195 self.flash('Finished')196 return197 198 def render(self):199 self.redirect(self.url(self.context, '@@index'))200 return -
main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils/helpers.py
r11824 r11947 235 235 grok.name(u'waeup.Factory') 236 236 title = u"Create instances of ``factory``.", 237 description = u"This factory instantiates new applicant instances."237 description = u"This factory instantiates new e.g. applicant instances." 238 238 factory = None 239 239 -
main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils/tests/test_converters.py
r8216 r11947 38 38 DELETION_MARKER, IGNORE_MARKER) 39 39 from waeup.kofa.schoolgrades import ResultEntryField 40 from waeup.kofa.university import Faculty41 40 from waeup.kofa.utils.converters import ( 42 41 IObjectConverter, IFieldConverter, DefaultFieldConverter, -
main/waeup.kofa/branches/henrik-regista/src/waeup/kofa/utils/utils.py
r11821 r11947 258 258 """Send credentials as email. 259 259 260 Input is the applicantfor which credentials are sent and the260 Input is the customer for which credentials are sent and the 261 261 password. 262 262
Note: See TracChangeset for help on using the changeset viewer.