Changeset 9484 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 31 Oct 2012, 16:01:42 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9467 r9484 390 390 form_fields = grok.AutoFields(IContactForm).select('subject', 'body') 391 391 392 def update(self, subject=u'' ):392 def update(self, subject=u'', body=u''): 393 393 self.form_fields.get('subject').field.default = subject 394 self.form_fields.get('body').field.default = body 394 395 self.subject = subject 395 396 return … … 586 587 form_fields = grok.AutoFields( 587 588 IUGStudentClearance).omit('clearance_locked') 589 if not getattr(self.context, 'clearance_comment'): 590 form_fields = form_fields.omit('clearance_comment') 591 else: 592 form_fields['clearance_comment'].custom_widget = BytesDisplayWidget 588 593 return form_fields 589 594 … … 610 615 form_fields = grok.AutoFields( 611 616 IUGStudentClearance).omit('clearance_locked') 617 if not getattr(self.context, 'clearance_comment'): 618 form_fields = form_fields.omit('clearance_comment') 612 619 return form_fields 613 620 … … 694 701 return 695 702 696 class StudentRejectClearancePage( UtilityView, grok.View):703 class StudentRejectClearancePage(KofaEditFormPage): 697 704 """ Reject clearance by clearance officers 698 705 """ 699 706 grok.context(IStudent) 700 707 grok.name('reject_clearance') 708 label = _('Reject clearance') 701 709 grok.require('waeup.clearStudent') 702 703 def update(self): 710 form_fields = grok.AutoFields( 711 IUGStudentClearance).select('clearance_comment') 712 713 @action(_('Save comment and reject clearance now'), style='primary') 714 def reject(self, **data): 704 715 if self.context.state == CLEARED: 705 716 IWorkflowInfo(self.context).fireTransition('reset4') … … 714 725 self.redirect(self.url(self.context,'view_clearance')) 715 726 return 716 args = {'subject':message} 727 self.applyData(self.context, **data) 728 comment = data['clearance_comment'] 729 self.context.writeLogMessage( 730 self, 'comment: %s' % comment.replace('\n', '<br>')) 731 args = {'subject':message, 'body':comment} 717 732 self.redirect(self.url(self.context) + 718 733 '/contactstudent?%s' % urlencode(args)) 719 734 return 720 735 721 def render(self):722 return736 #def render(self): 737 # return 723 738 724 739 class StudentPersonalDisplayFormPage(KofaDisplayFormPage): … … 1938 1953 if self.context.is_postgrad: 1939 1954 form_fields = grok.AutoFields(IPGStudentClearance).omit( 1940 'clearance_locked', 'clr_code' )1955 'clearance_locked', 'clr_code', 'clearance_comment') 1941 1956 else: 1942 1957 form_fields = grok.AutoFields(IUGStudentClearance).omit( 1943 'clearance_locked', 'clr_code' )1958 'clearance_locked', 'clr_code', 'clearance_comment') 1944 1959 return form_fields 1945 1960 -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r9437 r9484 274 274 ) 275 275 276 clearance_comment = schema.Text( 277 title = _(u"Officer's Comment"), 278 required = False, 279 #description = _( 280 # u'This comment will be deleted when student is cleared.'), 281 ) 282 276 283 class IPGStudentClearance(IUGStudentClearance): 277 284 """Representation of postgraduate student clearance data. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9452 r9484 1209 1209 self.browser.open(self.clearance_path) 1210 1210 self.browser.getLink("Reject clearance").click() 1211 self.assertEqual( 1212 self.browser.url, self.student_path + '/reject_clearance') 1213 # Type comment why 1214 self.browser.getControl(name="form.clearance_comment").value = """Dear Student, 1215 You did not fill properly. 1216 """ 1217 self.browser.getControl("Save comment").click() 1211 1218 self.assertTrue('Clearance has been annulled' in self.browser.contents) 1212 urlmessage = 'Clearance+has+been+annulled.' 1213 # CO does now see the contact form 1214 self.assertEqual(self.browser.url, self.student_path + 1215 '/contactstudent?subject=%s' % urlmessage) 1219 url = ('http://localhost/app/students/K1000000/' 1220 'contactstudent?body=Dear+Student%2C%0AYou+did+not+fill+properly.' 1221 '%0A&subject=Clearance+has+been+annulled.') 1222 # CO does now see the prefilled contact form and can send a message 1223 self.assertEqual(self.browser.url, url) 1216 1224 self.assertTrue('clearance started' in self.browser.contents) 1225 self.assertTrue('name="form.subject" size="20" type="text" ' 1226 'value="Clearance has been annulled."' 1227 in self.browser.contents) 1228 self.assertTrue('name="form.body" rows="10" >Dear Student,' 1229 in self.browser.contents) 1230 self.browser.getControl("Send message now").click() 1231 self.assertTrue('Your message has been sent' in self.browser.contents) 1232 # The comment has been stored ... 1233 self.assertEqual(self.student.clearance_comment, 1234 u'Dear Student,\nYou did not fill properly.\n') 1235 # ... and logged 1236 logfile = os.path.join( 1237 self.app['datacenter'].storage, 'logs', 'students.log') 1238 logcontent = open(logfile).read() 1239 self.assertTrue( 1240 'INFO - mrclear - students.browser.StudentRejectClearancePage - ' 1241 'K1000000 - comment: Dear Student,<br>You did not fill ' 1242 'properly.<br>\n' in logcontent) 1217 1243 self.browser.open(self.history_path) 1218 1244 self.assertTrue("Reset to 'clearance started' by My Public Name" in … … 1221 1247 self.browser.open(self.clearance_path) 1222 1248 self.browser.getLink("Reject clearance").click() 1249 self.browser.getControl("Save comment").click() 1223 1250 self.assertTrue('Clearance request has been rejected' 1224 1251 in self.browser.contents) 1225 1252 self.assertTrue('clearance started' in self.browser.contents) 1226 # CO does now also see the contact form and can send a message1227 self.browser.getControl(name="form.subject").value = 'Important subject'1228 self.browser.getControl(name="form.body").value = 'Clearance rejected'1229 self.browser.getControl("Send message now").click()1230 self.assertTrue('Your message has been sent' in self.browser.contents)1231 1253 # The CO can't clear students if not in state 1232 1254 # clearance requested … … 1240 1262 self.browser.getLink("Show students").click() 1241 1263 self.assertTrue(self.student_id in self.browser.contents) 1264 1265 1266 # When a student is cleared the comment is automatically deleted 1267 IWorkflowInfo(self.student).fireTransition('request_clearance') 1268 IWorkflowInfo(self.student).fireTransition('clear') 1269 self.assertEqual(self.student.clearance_comment, None) 1270 1242 1271 1243 1272 def test_handle_courses_by_ca(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9427 r9484 43 43 result = open(self.outfile, 'rb').read() 44 44 self.assertTrue( 45 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 45 'adm_code,clearance_comment,clearance_locked,clr_code,' 46 'date_of_birth,email,employer,' 46 47 'firstname,lastname,matric_number,middlename,nationality,' 47 48 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 48 49 'state,history,certcode,is_postgrad,current_level,current_session\r\n' 49 50 50 'my adm code, 0,my clr code,1981-02-04#,anna@sample.com,,'51 'my adm code,,0,my clr code,1981-02-04#,anna@sample.com,,' 51 52 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 52 53 '+234-123-12345#,123,f,A111111,0,,created' … … 63 64 result = open(self.outfile, 'rb').read() 64 65 self.assertTrue( 65 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 66 'adm_code,clearance_comment,clearance_locked,clr_code,' 67 'date_of_birth,email,employer,' 66 68 'firstname,lastname,matric_number,middlename,nationality,' 67 69 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 68 70 'state,history,certcode,is_postgrad,current_level,current_session\r\n' 69 71 70 'my adm code, 0,my clr code,1981-02-04#,anna@sample.com,,'72 'my adm code,,0,my clr code,1981-02-04#,anna@sample.com,,' 71 73 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 72 74 '+234-123-12345#,123,f,A111111,0,,created' … … 82 84 result = open(self.outfile, 'rb').read() 83 85 self.assertTrue( 84 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 86 'adm_code,clearance_comment,clearance_locked,clr_code,' 87 'date_of_birth,email,employer,' 85 88 'firstname,lastname,matric_number,middlename,nationality,' 86 89 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 87 90 'state,history,certcode,is_postgrad,current_level,current_session\r\n' 88 91 89 'my adm code, 0,my clr code,1981-02-04#,anna@sample.com,,'92 'my adm code,,0,my clr code,1981-02-04#,anna@sample.com,,' 90 93 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 91 94 '+234-123-12345#,123,f,A111111,0,,created' -
main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py
r9295 r9484 256 256 level_object.validated_by = usertitle 257 257 level_object.validation_date = datetime.utcnow() 258 elif event.transition.transition_id == 'clear': 259 obj.clearance_comment = None 258 260 elif event.transition.transition_id == 'reset8': 259 261 current_level = obj['studycourse'].current_level
Note: See TracChangeset for help on using the changeset viewer.