Changeset 7811 for main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
- Timestamp:
- 8 Mar 2012, 19:00:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r7745 r7811 29 29 from zope.formlib.textwidgets import BytesDisplayWidget 30 30 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 31 from waeup. sirp.accesscodes import (31 from waeup.kofa.accesscodes import ( 32 32 invalidate_accesscode, get_access_code, create_accesscode) 33 from waeup. sirp.accesscodes.workflow import USED34 from waeup. sirp.browser import (35 SIRPPage, SIRPEditFormPage, SIRPAddFormPage, SIRPDisplayFormPage,36 ContactAdminForm, SIRPForm)37 from waeup. sirp.browser.interfaces import ICaptchaManager38 from waeup. sirp.browser.breadcrumbs import Breadcrumb39 from waeup. sirp.browser.resources import datepicker, datatable, tabs, warning40 from waeup. sirp.browser.layout import jsaction, action, UtilityView41 from waeup. sirp.interfaces import (42 I SIRPObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm,43 I SIRPUtils, IUniversity)44 from waeup. sirp.interfaces import MessageFactory as _45 from waeup. sirp.widgets.datewidget import (33 from waeup.kofa.accesscodes.workflow import USED 34 from waeup.kofa.browser import ( 35 KOFAPage, KOFAEditFormPage, KOFAAddFormPage, KOFADisplayFormPage, 36 ContactAdminForm, KOFAForm) 37 from waeup.kofa.browser.interfaces import ICaptchaManager 38 from waeup.kofa.browser.breadcrumbs import Breadcrumb 39 from waeup.kofa.browser.resources import datepicker, datatable, tabs, warning 40 from waeup.kofa.browser.layout import jsaction, action, UtilityView 41 from waeup.kofa.interfaces import ( 42 IKOFAObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm, 43 IKOFAUtils, IUniversity) 44 from waeup.kofa.interfaces import MessageFactory as _ 45 from waeup.kofa.widgets.datewidget import ( 46 46 FriendlyDateWidget, FriendlyDateDisplayWidget, 47 47 FriendlyDatetimeDisplayWidget) 48 from waeup. sirp.students.interfaces import (48 from waeup.kofa.students.interfaces import ( 49 49 IStudentsContainer, IStudent, IStudentClearance, 50 50 IStudentPersonal, IStudentBase, IStudentStudyCourse, … … 53 53 IStudentOnlinePayment, IBedTicket, IStudentsUtils, IStudentChangePassword 54 54 ) 55 from waeup. sirp.students.catalog import search56 from waeup. sirp.students.workflow import (ADMITTED, PAID,55 from waeup.kofa.students.catalog import search 56 from waeup.kofa.students.workflow import (ADMITTED, PAID, 57 57 CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED) 58 from waeup. sirp.students.studylevel import StudentStudyLevel, CourseTicket59 from waeup. sirp.students.vocabularies import StudyLevelSource60 from waeup. sirp.browser.resources import toggleall61 from waeup. sirp.hostels.hostel import NOT_OCCUPIED62 from waeup. sirp.utils.helpers import get_current_principal58 from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket 59 from waeup.kofa.students.vocabularies import StudyLevelSource 60 from waeup.kofa.browser.resources import toggleall 61 from waeup.kofa.hostels.hostel import NOT_OCCUPIED 62 from waeup.kofa.utils.helpers import get_current_principal 63 63 64 64 def write_log_message(view, message): 65 ob_class = view.__implemented__.__name__.replace('waeup. sirp.','')65 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 66 66 view.context.getStudent().loggerInfo(ob_class, message) 67 67 return … … 155 155 @property 156 156 def title(self): 157 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE157 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 158 158 # There is no request attribute, thus we can only translate 159 159 # to the default (portal) language 160 return translate(self.context.level_title, 'waeup. sirp',160 return translate(self.context.level_title, 'waeup.kofa', 161 161 target_language=portal_language) 162 162 163 class StudentsContainerPage( SIRPPage):163 class StudentsContainerPage(KOFAPage): 164 164 """The standard view for student containers. 165 165 """ … … 194 194 return 195 195 196 class StudentsContainerManagePage( SIRPPage):196 class StudentsContainerManagePage(KOFAPage): 197 197 """The manage page for student containers. 198 198 """ … … 245 245 return 246 246 247 class StudentAddFormPage( SIRPAddFormPage):247 class StudentAddFormPage(KOFAAddFormPage): 248 248 """Add-form to add a student. 249 249 """ … … 265 265 return 266 266 267 class StudentBaseDisplayFormPage( SIRPDisplayFormPage):267 class StudentBaseDisplayFormPage(KOFADisplayFormPage): 268 268 """ Page to display student base data 269 269 """ … … 310 310 usertype = getattr(self.request.principal, 311 311 'user_type', 'system').title() 312 sirp_utils = getUtility(ISIRPUtils)313 success = sirp_utils.sendContactForm(312 kofa_utils = getUtility(IKOFAUtils) 313 success = kofa_utils.sendContactForm( 314 314 self.request.principal.title,email, 315 315 self.context.display_fullname,self.context.email, … … 323 323 return 324 324 325 class StudentBaseManageFormPage( SIRPEditFormPage):325 class StudentBaseManageFormPage(KOFAEditFormPage): 326 326 """ View to manage student base data 327 327 """ … … 388 388 return 389 389 390 class StudentClearanceDisplayFormPage( SIRPDisplayFormPage):390 class StudentClearanceDisplayFormPage(KOFADisplayFormPage): 391 391 """ Page to display student clearance data 392 392 """ … … 415 415 @property 416 416 def title(self): 417 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE418 return translate(_('Clearance Data'), 'waeup. sirp',417 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 418 return translate(_('Clearance Data'), 'waeup.kofa', 419 419 target_language=portal_language) 420 420 421 421 @property 422 422 def label(self): 423 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE423 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 424 424 return translate(_('Clearance Slip of '), 425 'waeup. sirp', target_language=portal_language) \425 'waeup.kofa', target_language=portal_language) \ 426 426 + ' %s' % self.context.display_fullname 427 427 … … 434 434 self.context.getStudent(), studentview) 435 435 436 class StudentClearanceManageFormPage( SIRPEditFormPage):436 class StudentClearanceManageFormPage(KOFAEditFormPage): 437 437 """ Page to edit student clearance data 438 438 """ … … 508 508 return 509 509 510 class StudentPersonalDisplayFormPage( SIRPDisplayFormPage):510 class StudentPersonalDisplayFormPage(KOFADisplayFormPage): 511 511 """ Page to display student personal data 512 512 """ … … 523 523 mapping = {'a':self.context.display_fullname}) 524 524 525 class StudentPersonalManageFormPage( SIRPEditFormPage):525 class StudentPersonalManageFormPage(KOFAEditFormPage): 526 526 """ Page to edit student clearance data 527 527 """ … … 538 538 return 539 539 540 class StudyCourseDisplayFormPage( SIRPDisplayFormPage):540 class StudyCourseDisplayFormPage(KOFADisplayFormPage): 541 541 """ Page to display the student study course data 542 542 """ … … 556 556 def current_mode(self): 557 557 if self.context.certificate is not None: 558 studymodes_dict = getUtility(I SIRPUtils).getStudyModesDict()558 studymodes_dict = getUtility(IKOFAUtils).getStudyModesDict() 559 559 return studymodes_dict[self.context.certificate.study_mode] 560 560 return … … 572 572 return 573 573 574 class StudyCourseManageFormPage( SIRPEditFormPage):574 class StudyCourseManageFormPage(KOFAEditFormPage): 575 575 """ Page to edit the student study course data 576 576 """ … … 645 645 return 646 646 647 class StudyLevelDisplayFormPage( SIRPDisplayFormPage):647 class StudyLevelDisplayFormPage(KOFADisplayFormPage): 648 648 """ Page to display student study levels 649 649 """ … … 662 662 @property 663 663 def label(self): 664 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE665 lang = self.request.cookies.get(' sirp.language', portal_language)666 level_title = translate(self.context.level_title, 'waeup. sirp',664 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 665 lang = self.request.cookies.get('kofa.language', portal_language) 666 level_title = translate(self.context.level_title, 'waeup.kofa', 667 667 target_language=lang) 668 668 return _('${a}: Study Level ${b}', mapping = { … … 688 688 @property 689 689 def title(self): 690 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE691 return translate(_('Level Data'), 'waeup. sirp',690 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 691 return translate(_('Level Data'), 'waeup.kofa', 692 692 target_language=portal_language) 693 693 694 694 @property 695 695 def content_title(self): 696 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE697 return translate(_('Course List'), 'waeup. sirp',696 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 697 return translate(_('Course List'), 'waeup.kofa', 698 698 target_language=portal_language) 699 699 700 700 @property 701 701 def label(self): 702 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE703 lang = self.request.cookies.get(' sirp.language', portal_language)704 level_title = translate(self.context.level_title, 'waeup. sirp',702 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 703 lang = self.request.cookies.get('kofa.language', portal_language) 704 level_title = translate(self.context.level_title, 'waeup.kofa', 705 705 target_language=lang) 706 706 return translate(_('Course Registration Slip '), 707 'waeup. sirp', target_language=portal_language) \707 'waeup.kofa', target_language=portal_language) \ 708 708 + ' %s' % level_title 709 709 710 710 def render(self): 711 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE712 Sem = translate(_('Sem.'), 'waeup. sirp', target_language=portal_language)713 Code = translate(_('Code'), 'waeup. sirp', target_language=portal_language)714 Title = translate(_('Title'), 'waeup. sirp', target_language=portal_language)715 Dept = translate(_('Dept.'), 'waeup. sirp', target_language=portal_language)716 Faculty = translate(_('Faculty'), 'waeup. sirp', target_language=portal_language)717 Cred = translate(_('Cred.'), 'waeup. sirp', target_language=portal_language)718 Mand = translate(_('Mand.'), 'waeup. sirp', target_language=portal_language)719 Score = translate(_('Score'), 'waeup. sirp', target_language=portal_language)711 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 712 Sem = translate(_('Sem.'), 'waeup.kofa', target_language=portal_language) 713 Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) 714 Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) 715 Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language) 716 Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language) 717 Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language) 718 Mand = translate(_('Mand.'), 'waeup.kofa', target_language=portal_language) 719 Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) 720 720 studentview = StudentBaseDisplayFormPage(self.context.getStudent(), 721 721 self.request) … … 735 735 tabledata=tabledata) 736 736 737 class StudyLevelManageFormPage( SIRPEditFormPage):737 class StudyLevelManageFormPage(KOFAEditFormPage): 738 738 """ Page to edit the student study level data 739 739 """ … … 762 762 @property 763 763 def label(self): 764 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE765 lang = self.request.cookies.get(' sirp.language', portal_language)766 level_title = translate(self.context.level_title, 'waeup. sirp',764 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 765 lang = self.request.cookies.get('kofa.language', portal_language) 766 level_title = translate(self.context.level_title, 'waeup.kofa', 767 767 target_language=lang) 768 768 return _('Manage study level ${a}', … … 853 853 return 854 854 855 class CourseTicketAddFormPage( SIRPAddFormPage):855 class CourseTicketAddFormPage(KOFAAddFormPage): 856 856 """Add a course ticket. 857 857 """ … … 890 890 self.redirect(self.url(self.context)) 891 891 892 class CourseTicketDisplayFormPage( SIRPDisplayFormPage):892 class CourseTicketDisplayFormPage(KOFADisplayFormPage): 893 893 """ Page to display course tickets 894 894 """ … … 906 906 'b':self.context.code}) 907 907 908 class CourseTicketManageFormPage( SIRPEditFormPage):908 class CourseTicketManageFormPage(KOFAEditFormPage): 909 909 """ Page to manage course tickets 910 910 """ … … 925 925 return 926 926 927 class PaymentsManageFormPage( SIRPEditFormPage):927 class PaymentsManageFormPage(KOFAEditFormPage): 928 928 """ Page to manage the student payments 929 929 … … 982 982 self.redirect(self.url(self.context, '@@addop')) 983 983 984 class OnlinePaymentAddFormPage( SIRPAddFormPage):984 class OnlinePaymentAddFormPage(KOFAAddFormPage): 985 985 """ Page to add an online payment ticket 986 986 """ … … 1039 1039 return 1040 1040 1041 class OnlinePaymentDisplayFormPage( SIRPDisplayFormPage):1041 class OnlinePaymentDisplayFormPage(KOFADisplayFormPage): 1042 1042 """ Page to view an online payment ticket 1043 1043 """ … … 1138 1138 1139 1139 1140 class AccommodationManageFormPage( SIRPEditFormPage):1140 class AccommodationManageFormPage(KOFAEditFormPage): 1141 1141 """ Page to manage bed tickets. 1142 1142 … … 1195 1195 return self.actions 1196 1196 1197 class BedTicketAddPage( SIRPPage):1197 class BedTicketAddPage(KOFAPage): 1198 1198 """ Page to add an online payment ticket 1199 1199 """ … … 1287 1287 'c':room_nr, 'd':bed_nr, 1288 1288 'e':bed.bed_type}) 1289 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE1289 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 1290 1290 bedticket.bed_coordinates = translate( 1291 bc, 'waeup. sirp',target_language=portal_language)1291 bc, 'waeup.kofa',target_language=portal_language) 1292 1292 key = str(acc_details['booking_session']) 1293 1293 self.context[key] = bedticket … … 1297 1297 return 1298 1298 1299 class BedTicketDisplayFormPage( SIRPDisplayFormPage):1299 class BedTicketDisplayFormPage(KOFADisplayFormPage): 1300 1300 """ Page to display bed tickets 1301 1301 """ … … 1325 1325 @property 1326 1326 def title(self): 1327 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE1328 return translate(_('Bed Allocation Data'), 'waeup. sirp',1327 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 1328 return translate(_('Bed Allocation Data'), 'waeup.kofa', 1329 1329 target_language=portal_language) 1330 1330 1331 1331 @property 1332 1332 def label(self): 1333 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE1333 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 1334 1334 return translate(_('Bed Allocation: '), 1335 'waeup. sirp', target_language=portal_language) \1335 'waeup.kofa', target_language=portal_language) \ 1336 1336 + ' %s' % self.context.bed_coordinates 1337 1337 … … 1405 1405 'c':room_nr, 'd':bed_nr, 1406 1406 'e':new_bed.bed_type}) 1407 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE1407 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 1408 1408 self.context.bed_coordinates = translate( 1409 bc, 'waeup. sirp',target_language=portal_language)1409 bc, 'waeup.kofa',target_language=portal_language) 1410 1410 self.flash(_('Student relocated: ${a}', 1411 1411 mapping = {'a':self.context.bed_coordinates})) … … 1416 1416 return 1417 1417 1418 class StudentHistoryPage( SIRPPage):1418 class StudentHistoryPage(KOFAPage): 1419 1419 """ Page to display student clearance data 1420 1420 """ … … 1431 1431 # Pages for students only 1432 1432 1433 class StudentBaseEditFormPage( SIRPEditFormPage):1433 class StudentBaseEditFormPage(KOFAEditFormPage): 1434 1434 """ View to edit student base data 1435 1435 """ … … 1447 1447 return 1448 1448 1449 class StudentChangePasswordPage( SIRPEditFormPage):1449 class StudentChangePasswordPage(KOFAEditFormPage): 1450 1450 """ View to manage student base data 1451 1451 """ … … 1473 1473 return 1474 1474 1475 class StudentFilesUploadPage( SIRPPage):1475 class StudentFilesUploadPage(KOFAPage): 1476 1476 """ View to upload files by student 1477 1477 """ … … 1490 1490 return 1491 1491 1492 class StartClearancePage( SIRPPage):1492 class StartClearancePage(KOFAPage): 1493 1493 grok.context(IStudent) 1494 1494 grok.name('start_clearance') … … 1593 1593 return 1594 1594 1595 class RequestClearancePage( SIRPPage):1595 class RequestClearancePage(KOFAPage): 1596 1596 grok.context(IStudent) 1597 1597 grok.name('request_clearance') … … 1624 1624 return 1625 1625 1626 class StartCourseRegistrationPage( SIRPPage):1626 class StartCourseRegistrationPage(KOFAPage): 1627 1627 grok.context(IStudentStudyCourse) 1628 1628 grok.name('start_course_registration') … … 1673 1673 return 1674 1674 1675 class AddStudyLevelFormPage( SIRPEditFormPage):1675 class AddStudyLevelFormPage(KOFAEditFormPage): 1676 1676 """ Page for students to add current study levels 1677 1677 """ … … 1710 1710 return 1711 1711 1712 class StudyLevelEditFormPage( SIRPEditFormPage):1712 class StudyLevelEditFormPage(KOFAEditFormPage): 1713 1713 """ Page to edit the student study level data by students 1714 1714 """ … … 1732 1732 @property 1733 1733 def label(self): 1734 portal_language = getUtility(I SIRPUtils).PORTAL_LANGUAGE1735 lang = self.request.cookies.get(' sirp.language', portal_language)1736 level_title = translate(self.context.level_title, 'waeup. sirp',1734 portal_language = getUtility(IKOFAUtils).PORTAL_LANGUAGE 1735 lang = self.request.cookies.get('kofa.language', portal_language) 1736 level_title = translate(self.context.level_title, 'waeup.kofa', 1737 1737 target_language=lang) 1738 1738 return _('Add and remove course tickets of study level ${a}', … … 1816 1816 return 1817 1817 1818 class ChangePasswordRequestPage( SIRPForm):1818 class ChangePasswordRequestPage(KOFAForm): 1819 1819 """Captcha'd page for students to request a password change. 1820 1820 """ … … 1851 1851 student = list(results)[0] 1852 1852 # Change password 1853 sirp_utils = getUtility(ISIRPUtils)1854 pwd = sirp_utils.genPassword()1853 kofa_utils = getUtility(IKOFAUtils) 1854 pwd = kofa_utils.genPassword() 1855 1855 IUserAccount(student).setPassword(pwd) 1856 1856 # Send email with new redentials 1857 1857 msg = _('You have successfully changed your password for the') 1858 1858 login_url = self.url(grok.getSite(), 'login') 1859 success = sirp_utils.sendCredentials(1859 success = kofa_utils.sendCredentials( 1860 1860 IUserAccount(student),pwd,login_url,msg) 1861 1861 if success: … … 1866 1866 return 1867 1867 1868 class SetPasswordPage( SIRPPage):1869 grok.context(I SIRPObject)1868 class SetPasswordPage(KOFAPage): 1869 grok.context(IKOFAObject) 1870 1870 grok.name('setpassword') 1871 1871 grok.require('waeup.Anonymous')
Note: See TracChangeset for help on using the changeset viewer.