Changeset 7363 for main/waeup.sirp/trunk/src
- Timestamp:
- 16 Dec 2011, 13:50:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7356 r7363 34 34 Table, Spacer) 35 35 from reportlab.platypus.tables import TableStyle 36 from waeup.sirp.applicants.interfaces import ( 37 IApplicant, IApplicantEdit, IApplicantsRoot, 38 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab, 39 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, 40 ) 41 from waeup.sirp.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED 36 42 from waeup.sirp.browser import ( 37 SIRPPage, SIRPEditFormPage, SIRPAddFormPage, SIRPDisplayFormPage) 43 SIRPPage, SIRPEditFormPage, SIRPAddFormPage, SIRPDisplayFormPage, 44 DEFAULT_PASSPORT_IMAGE_PATH) 45 from waeup.sirp.browser.interfaces import ICaptchaManager 38 46 from waeup.sirp.browser.breadcrumbs import Breadcrumb 39 47 from waeup.sirp.browser.layout import NullValidator, jsaction, JSAction … … 45 53 IFileStoreNameChooser, IPasswordValidator, IUserAccount) 46 54 from waeup.sirp.permissions import get_users_with_local_roles 47 from waeup.sirp.browser import DEFAULT_PASSPORT_IMAGE_PATH 55 from waeup.sirp.students.viewlets import PrimaryStudentNavTab 56 from waeup.sirp.students.interfaces import IStudentsUtils 48 57 from waeup.sirp.university.interfaces import ICertificate 49 58 from waeup.sirp.utils.helpers import string_from_bytes, file_size … … 51 60 FriendlyDateWidget, FriendlyDateDisplayWidget, 52 61 FriendlyDatetimeDisplayWidget) 62 from waeup.sirp.widgets.phonewidget import PhoneWidget 53 63 from waeup.sirp.widgets.restwidget import ReSTDisplayWidget 54 from waeup.sirp.applicants.interfaces import (55 IApplicant, IApplicantEdit, IApplicantsRoot,56 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab,57 MAX_UPLOAD_SIZE, IApplicantOnlinePayment,58 )59 from waeup.sirp.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED60 from waeup.sirp.students.viewlets import PrimaryStudentNavTab61 from waeup.sirp.students.interfaces import IStudentsUtils62 64 63 65 grok.context(ISIRPObject) # Make ISIRPObject the default context … … 303 305 text = 'Manage applicants container' 304 306 305 #class ApplicantLoginActionButton(ManageActionButton):306 # grok.order(2)307 # grok.context(IApplicantsContainer)308 # grok.view(ApplicantsContainerPage)309 # grok.require('waeup.Anonymous')310 # icon = 'login.png'311 # text = 'Login for applicants'312 # target = 'login'313 314 307 class ApplicantsContainerManageFormPage(SIRPEditFormPage): 315 308 grok.context(IApplicantsContainer) … … 429 422 self.context.addApplicant(applicant) 430 423 self.flash('Applicant record created.') 431 self.redirect(self.url(self.context[applicant.application_number], 'index')) 424 self.redirect( 425 self.url(self.context[applicant.application_number], 'index')) 432 426 return 433 427 … … 520 514 return 521 515 timestamp = "%d" % int(time()*1000) 522 #order_id = "%s%s" % (student_id[1:],timestamp)523 516 for key in self.context.keys(): 524 517 ticket = self.context[key] … … 557 550 grok.require('waeup.viewApplication') 558 551 form_fields = grok.AutoFields(IApplicantOnlinePayment) 559 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 560 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 552 form_fields[ 553 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 554 form_fields[ 555 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 561 556 pnav = 3 562 557 … … 952 947 self.flash('Successfully removed: %s' % ', '.join(deleted)) 953 948 ob_class = self.__implemented__.__name__.replace('waeup.sirp.','') 954 self.context.loggerInfo(ob_class, 'removed: % s' % ', '.join(deleted)) 949 self.context.loggerInfo( 950 ob_class, 'removed: % s' % ', '.join(deleted)) 955 951 return 956 952 … … 980 976 ) 981 977 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 978 #form_fields['phone'].custom_widget = PhoneWidget 982 979 grok.template('applicanteditpage') 983 980 manage_applications = False … … 1091 1088 return open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb').read() 1092 1089 return image 1090 1091 class ApplicantRegistrationSuccessful(SIRPPage): 1092 """Info page when applicant registration was successful. 1093 """ 1094 grok.context(IApplicantsContainer) 1095 grok.name('register_success') 1096 grok.require('waeup.Public') 1097 grok.template('applicantregister_succ') 1098 label = 'Applicant Registration Successful' 1099 title = label 1100 1101 def update(self, app_id=None): 1102 if app_id is None: 1103 self.redirect(self.url(self.context, 'register')) 1104 self.app_id = app_id 1105 self.login_url = self.url(grok.getSite(), 'login') 1106 1107 class ApplicantRegistrationPage(SIRPAddFormPage): 1108 """Captcha'd registration page for applicants. 1109 """ 1110 grok.context(IApplicantsContainer) 1111 grok.name('register') 1112 grok.require('waeup.Public') 1113 grok.template('applicantregister') 1114 label = 'Applicant Registration' 1115 title = label 1116 form_fields = grok.AutoFields(IApplicantEdit).select( 1117 'firstname', 'middlename', 'lastname', 'email', 'phone') 1118 form_fields['phone'].custom_widget = PhoneWidget 1119 1120 def update(self): 1121 # handle captcha 1122 self.captcha = getUtility(ICaptchaManager).getCaptcha() 1123 self.captcha_result = self.captcha.verify(self.request) 1124 self.captcha_code = self.captcha.display(self.captcha_result.error_code) 1125 return 1126 1127 @grok.action('Register') 1128 def register(self, **data): 1129 if not self.captcha_result.is_valid: 1130 # captcha will display error messages automatically. 1131 # No need to flash something. 1132 return 1133 1134 # handle password field manually 1135 form = self.request.form 1136 password = form.get('password', None) 1137 password_ctl = form.get('control_password', None) 1138 if password: 1139 validator = getUtility(IPasswordValidator) 1140 errors = validator.validate_password(password, password_ctl) 1141 if errors: 1142 self.flash( ' '.join(errors)) 1143 return 1144 1145 # add applicant and redirect to success page 1146 applicant = createObject('waeup.Applicant') 1147 self.applyData(applicant, **data) 1148 self.context.addApplicant(applicant) 1149 IUserAccount(applicant).setPassword(password) 1150 app_id = applicant.applicant_id 1151 self.redirect(self.url(self.context, 'register_success', 1152 data=dict(app_id=app_id))) 1153 return
Note: See TracChangeset for help on using the changeset viewer.