- Timestamp:
- 14 Jun 2016, 01:38:12 (8 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk
- Property svn:mergeinfo changed
/main/waeup.kofa/branches/uli-scores-upload merged: 13913-13934
- Property svn:mergeinfo changed
-
main/waeup.kofa/trunk/src/waeup/kofa
- Property svn:mergeinfo changed
/main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa merged: 13913-13934
- Property svn:mergeinfo changed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r13610 r13935 18 18 import grok 19 19 from zope.component import getUtility 20 from zope.i18n import translate 20 21 from zope.interface import Interface 21 from zope.i18n import translate 22 from waeup.kofa.interfaces import IExtFileStore, IKofaObject 23 from waeup.kofa.interfaces import MessageFactory as _ 22 from waeup.kofa.browser.layout import default_primary_nav_template 24 23 from waeup.kofa.browser.viewlets import ( 25 24 PrimaryNavTab, ManageActionButton, AddActionButton) 26 from waeup.kofa.browser.layout import default_primary_nav_template 27 from waeup.kofa.students.workflow import ( 28 ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, 29 VALIDATED, GRADUATED, TRANSCRIPT) 25 from waeup.kofa.interfaces import MessageFactory as _ 26 from waeup.kofa.interfaces import IExtFileStore, IKofaObject 30 27 from waeup.kofa.students.browser import ( 31 StudentsContainerPage, 32 StudentsContainerManagePage, StudentBaseDisplayFormPage, 33 StudentClearanceDisplayFormPage, StudentPersonalDisplayFormPage, 34 StudyCourseDisplayFormPage, StudyLevelDisplayFormPage, 35 CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage, 36 AccommodationManageFormPage, BedTicketDisplayFormPage, 28 StudentsContainerPage, StudentsContainerManagePage, 29 StudentBaseDisplayFormPage, StudentClearanceDisplayFormPage, 30 StudentPersonalDisplayFormPage, StudyCourseDisplayFormPage, 31 StudyLevelDisplayFormPage, CourseTicketDisplayFormPage, 32 OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage, 37 33 StudentClearanceEditFormPage, StudentPersonalEditFormPage, 38 PaymentsManageFormPage, StudyCourseTranscriptPage )34 PaymentsManageFormPage, StudyCourseTranscriptPage, EditScoresPage) 39 35 from waeup.kofa.students.interfaces import ( 40 IStudentsContainer, IStudent, IStudentStudyCourse, IStudent Accommodation,41 I StudentStudyLevel, ICourseTicket, IStudentOnlinePayment, IBedTicket,36 IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel, 37 ICourseTicket, IStudentOnlinePayment, IBedTicket, 42 38 IStudentPaymentsContainer, IStudentsUtils 43 39 ) 44 45 grok.context(IKofaObject) # Make IKofaObject the default context 40 from waeup.kofa.students.workflow import ( 41 ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED, 42 TRANSCRIPT) 43 from waeup.kofa.university.interfaces import ICourse 44 45 46 grok.context(IKofaObject) # Make IKofaObject the default context 46 47 grok.templatedir('browser_templates') 47 48 … … 49 50 class StudentManageSidebar(grok.ViewletManager): 50 51 grok.name('left_studentmanage') 52 51 53 52 54 class StudentManageLink(grok.Viewlet): … … 69 71 # Here we know that the cookie has been set 70 72 lang = self.request.cookies.get('kofa.language') 71 text = translate( self.text, 'waeup.kofa',72 target_language=lang)73 text = translate( 74 self.text, 'waeup.kofa', target_language=lang) 73 75 if not self.link: 74 76 return '' 75 77 return u'<li><a href="%s">%s</a></li>' % ( 76 url, text) 78 url, text) 79 77 80 78 81 class StudentManageApplicationLink(StudentManageLink): … … 86 89 if slip: 87 90 lang = self.request.cookies.get('kofa.language') 88 text = translate( self.text, 'waeup.kofa',89 target_language=lang)90 url = self.view.url(self.context.student, self.link)91 text = translate( 92 self.text, 'waeup.kofa', target_language=lang) 93 url = self.view.url(self.context.student, self.link) 91 94 return u'<li><a href="%s">%s</a></li>' % ( 92 95 url, text) 93 96 return '' 97 94 98 95 99 class StudentManageBaseLink(StudentManageLink): … … 97 101 link = 'index' 98 102 text = _(u'Base Data') 103 99 104 100 105 class StudentManageClearanceLink(StudentManageLink): … … 104 109 text = _(u'Clearance Data') 105 110 111 106 112 class StudentManagePersonalLink(StudentManageLink): 107 113 grok.order(4) … … 110 116 text = _(u'Personal Data') 111 117 118 112 119 class StudentManageStudyCourseLink(StudentManageLink): 113 120 grok.order(5) 114 121 link = 'studycourse' 115 122 text = _(u'Study Course') 123 116 124 117 125 class StudentManagePaymentsLink(StudentManageLink): … … 120 128 link = 'payments' 121 129 text = _(u'Payments') 130 122 131 123 132 class StudentManageAccommodationLink(StudentManageLink): … … 128 137 text = _(u'Accommodation') 129 138 139 130 140 class StudentManageHistoryLink(StudentManageLink): 131 141 grok.order(8) … … 141 151 text = _('Manage students section') 142 152 153 143 154 class StudentsContainerAddActionButton(AddActionButton): 144 155 grok.order(1) … … 148 159 text = _('Add student') 149 160 target = 'addstudent' 161 150 162 151 163 class ContactActionButton(ManageActionButton): … … 158 170 target = 'contactstudent' 159 171 172 160 173 class StudentBaseManageActionButton(ManageActionButton): 161 174 grok.order(1) … … 165 178 text = _('Manage') 166 179 target = 'manage_base' 180 167 181 168 182 class StudentTrigTransActionButton(ManageActionButton): … … 175 189 target = 'trigtrans' 176 190 191 177 192 class StudentLoginAsActionButton(ManageActionButton): 178 193 grok.order(3) … … 184 199 target = 'loginasstep1' 185 200 201 186 202 class AdmissionSlipActionButton(ManageActionButton): 187 203 grok.order(4) … … 193 209 target = 'admission_slip.pdf' 194 210 211 195 212 class StudentTransferButton(ManageActionButton): 196 213 grok.order(6) … … 202 219 icon = 'actionicon_redo.png' 203 220 221 204 222 class StudentDeactivateActionButton(ManageActionButton): 205 223 grok.order(7) … … 222 240 "'A history message will be added. Are you sure?'") 223 241 242 224 243 class StudentActivateActionButton(ManageActionButton): 225 244 grok.order(7) … … 242 261 "'A history message will be added. Are you sure?'") 243 262 263 244 264 class StudentClearanceManageActionButton(ManageActionButton): 245 265 grok.order(1) … … 249 269 text = _('Manage') 250 270 target = 'manage_clearance' 271 251 272 252 273 class StudentClearActionButton(ManageActionButton): … … 261 282 @property 262 283 def target_url(self): 263 cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context) 284 cdm = getUtility( 285 IStudentsUtils).clearance_disabled_message(self.context) 264 286 if cdm: 265 287 return '' … … 267 289 return '' 268 290 return self.view.url(self.view.context, self.target) 291 269 292 270 293 class StudentRejectClearanceActionButton(ManageActionButton): … … 279 302 @property 280 303 def target_url(self): 281 cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context) 304 cdm = getUtility( 305 IStudentsUtils).clearance_disabled_message(self.context) 282 306 if cdm: 283 307 return '' … … 285 309 return '' 286 310 return self.view.url(self.view.context, self.target) 311 287 312 288 313 class ClearanceSlipActionButton(ManageActionButton): … … 295 320 target = 'clearance_slip.pdf' 296 321 322 297 323 class ClearanceViewActionButton(ManageActionButton): 298 324 grok.order(1) … … 304 330 target = 'view_clearance' 305 331 332 306 333 class PersonalViewActionButton(ManageActionButton): 307 334 grok.order(1) … … 313 340 target = 'view_personal' 314 341 342 315 343 class StudentPersonalManageActionButton(ManageActionButton): 316 344 grok.order(1) … … 321 349 target = 'manage_personal' 322 350 351 323 352 class StudentPersonalEditActionButton(ManageActionButton): 324 353 grok.order(2) … … 328 357 text = _('Edit') 329 358 target = 'edit_personal' 359 330 360 331 361 class StudyCourseManageActionButton(ManageActionButton): … … 342 372 return self.view.url(self.view.context, self.target) 343 373 return False 374 344 375 345 376 class StudyCourseTranscriptActionButton(ManageActionButton): … … 358 389 return False 359 390 391 360 392 class TranscriptSlipActionButton(ManageActionButton): 361 393 grok.order(1) … … 373 405 return False 374 406 407 375 408 class RevertTransferActionButton(ManageActionButton): 376 409 grok.order(1) … … 388 421 return False 389 422 423 390 424 class StudyLevelManageActionButton(ManageActionButton): 391 425 grok.order(1) … … 402 436 return '' 403 437 return self.view.url(self.view.context, self.target) 438 404 439 405 440 class StudentValidateCoursesActionButton(ManageActionButton): … … 414 449 @property 415 450 def target_url(self): 416 is_current = self.context.__parent__.is_current 417 if self.context.student.state != REGISTERED or \ 418 str(self.context.__parent__.current_level) != self.context.__name__ or\ 419 not is_current: 420 return '' 421 return self.view.url(self.view.context, self.target) 451 if not self.context.__parent__.is_current: 452 return '' 453 if self.context.student.state != REGISTERED: 454 return '' 455 if str(self.context.__parent__.current_level) != self.context.__name__: 456 return '' 457 return self.view.url(self.view.context, self.target) 458 422 459 423 460 class StudentRejectCoursesActionButton(ManageActionButton): … … 432 469 @property 433 470 def target_url(self): 434 is_current = self.context.__parent__.is_current 435 if self.context.student.state not in (VALIDATED, REGISTERED) or \ 436 str(self.context.__parent__.current_level) != self.context.__name__ or\ 437 not is_current: 438 return '' 439 return self.view.url(self.view.context, self.target) 471 if not self.context.__parent__.is_current: 472 return '' 473 if self.context.student.state not in (VALIDATED, REGISTERED): 474 return '' 475 if str(self.context.__parent__.current_level) != self.context.__name__: 476 return '' 477 return self.view.url(self.view.context, self.target) 478 440 479 441 480 class StudentUnregisterCoursesActionButton(ManageActionButton): … … 450 489 @property 451 490 def target_url(self): 452 is_current = self.context.__parent__.is_current 453 if self.context.student.state != REGISTERED or \ 454 str(self.context.__parent__.current_level) != self.context.__name__ or\ 455 not is_current: 456 return '' 457 return self.view.url(self.view.context, self.target) 491 if not self.context.__parent__.is_current: 492 return '' 493 if self.context.student.state != REGISTERED: 494 return '' 495 if str(self.context.__parent__.current_level) != self.context.__name__: 496 return '' 497 return self.view.url(self.view.context, self.target) 498 458 499 459 500 class CourseRegistrationSlipActionButton(ManageActionButton): … … 473 514 return self.view.url(self.view.context, self.target) 474 515 516 475 517 class CourseTicketManageActionButton(ManageActionButton): 476 518 grok.order(1) … … 481 523 target = 'manage' 482 524 483 #class OnlinePaymentManageActionButton(ManageActionButton):484 # grok.order(1)485 # grok.context(IStudentPaymentsContainer)486 # grok.view(PaymentsDisplayFormPage)487 # grok.require('waeup.manageStudent')488 # text = 'Manage payments'489 # target = 'manage'490 525 491 526 class PaymentReceiptActionButton(ManageActionButton): 492 grok.order(9) # This button should always be the last one.527 grok.order(9) # This button should always be the last one. 493 528 grok.context(IStudentOnlinePayment) 494 529 grok.view(OnlinePaymentDisplayFormPage) … … 503 538 # return '' 504 539 return self.view.url(self.view.context, self.target) 540 505 541 506 542 class ApprovePaymentActionButton(ManageActionButton): … … 519 555 return self.view.url(self.view.context, self.target) 520 556 557 521 558 class BedTicketSlipActionButton(ManageActionButton): 522 559 grok.order(1) … … 528 565 target = 'bed_allocation_slip.pdf' 529 566 567 530 568 class RelocateStudentActionButton(ManageActionButton): 531 569 grok.order(2) … … 537 575 target = 'relocate' 538 576 577 539 578 class StudentBaseActionButton(ManageActionButton): 540 579 grok.order(1) … … 544 583 text = _('Edit') 545 584 target = 'edit_base' 585 546 586 547 587 class StudentPasswordActionButton(ManageActionButton): … … 554 594 target = 'change_password' 555 595 596 556 597 class StudentPassportActionButton(ManageActionButton): 557 598 grok.order(3) … … 565 606 @property 566 607 def target_url(self): 567 PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES 608 PORTRAIT_CHANGE_STATES = getUtility( 609 IStudentsUtils).PORTRAIT_CHANGE_STATES 568 610 if self.context.state not in PORTRAIT_CHANGE_STATES: 569 611 return '' 570 612 return self.view.url(self.view.context, self.target) 613 571 614 572 615 class StudentClearanceStartActionButton(ManageActionButton): … … 585 628 return self.view.url(self.view.context, self.target) 586 629 630 587 631 class StudentClearanceEditActionButton(ManageActionButton): 588 632 grok.order(1) … … 598 642 return '' 599 643 return self.view.url(self.view.context, self.target) 644 600 645 601 646 class StartSessionActionButton(ManageActionButton): … … 613 658 return self.view.url(self.view.context, self.target) 614 659 return False 660 615 661 616 662 class AddStudyLevelActionButton(AddActionButton): … … 632 678 return '' 633 679 return self.view.url(self.view.context, self.target) 680 634 681 635 682 class StudyLevelEditActionButton(ManageActionButton): … … 651 698 return '' 652 699 700 653 701 class AddPaymentActionButton(AddActionButton): 654 702 grok.order(1) … … 658 706 text = _('Add current session payment ticket') 659 707 target = 'addop' 708 660 709 661 710 class AddPreviousPaymentActionButton(AddActionButton): … … 675 724 return self.view.url(self.view.context, self.target) 676 725 726 677 727 class AddBalancePaymentActionButton(AddActionButton): 678 728 grok.order(3) … … 690 740 return self.view.url(self.view.context, self.target) 691 741 742 692 743 class RequestTranscriptActionButton(ManageActionButton): 693 744 grok.order(8) … … 704 755 return '' 705 756 return self.view.url(self.view.context, self.target) 757 706 758 707 759 class ProcessTranscriptRequestActionButton(ManageActionButton): … … 720 772 return self.view.url(self.view.context, self.target) 721 773 774 722 775 class StudentsTab(PrimaryNavTab): 723 776 """Students tab in primary navigation. 724 777 """ 725 726 778 grok.context(IKofaObject) 727 779 grok.order(4) … … 736 788 return self.view.application_url('students') 737 789 790 738 791 class PrimaryStudentNavManager(grok.ViewletManager): 739 792 """Viewlet manager for the primary navigation tab. 740 793 """ 741 794 grok.name('primary_nav_student') 795 742 796 743 797 class PrimaryStudentNavTab(grok.Viewlet): … … 763 817 return 'active' 764 818 return '' 819 765 820 766 821 class MyStudentDataTab(PrimaryStudentNavTab): … … 789 844 targets = [] 790 845 if app_slip: 791 targets = [{'url': student_url + '/application_slip',792 'title': _('Application Slip')},]846 targets = [{'url': student_url + '/application_slip', 847 'title': _('Application Slip')}, ] 793 848 targets += [ 794 {'url':student_url, 'title':'Base Data'}, 795 {'url':student_url + '/view_clearance', 796 'title':_('Clearance Data')}, 797 {'url':student_url + '/view_personal', 'title':_('Personal Data')}, 798 {'url':student_url + '/studycourse', 'title':_('Study Course')}, 799 {'url':student_url + '/payments', 'title':_('Payments')}, 800 {'url':student_url + '/accommodation', 801 'title':_('Accommodation Data')}, 802 {'url':student_url + '/history', 'title':_('History')}, 849 {'url': student_url, 'title': 'Base Data'}, 850 {'url': student_url + '/view_clearance', 851 'title': _('Clearance Data')}, 852 {'url': student_url + '/view_personal', 853 'title': _('Personal Data')}, 854 {'url': student_url + '/studycourse', 'title': _('Study Course')}, 855 {'url': student_url + '/payments', 'title': _('Payments')}, 856 {'url': student_url + '/accommodation', 857 'title': _('Accommodation Data')}, 858 {'url': student_url + '/history', 'title': _('History')}, 803 859 ] 804 860 return targets 861 862 863 class DownloadCSVFileActionButton(ManageActionButton): 864 """ 'Download csv file' button for courses. 865 """ 866 grok.context(ICourse) 867 grok.view(EditScoresPage) 868 grok.name('downloadcsv') 869 grok.require('waeup.editScores') 870 icon = 'actionicon_down.png' 871 text = _('Download editable tickets') 872 target = 'download_scores' 873 grok.order(1) 874 875 876 class DownloadTicketOverviewActionButton(ManageActionButton): 877 """ 'Download ticket overview' button for courses. 878 """ 879 grok.context(ICourse) 880 grok.view(EditScoresPage) 881 grok.name('coursetickets') 882 grok.require('waeup.editScores') 883 icon = 'actionicon_pdf.png' 884 text = _('Download pdf file') 885 target = 'coursetickets.pdf' 886 grok.order(2)
Note: See TracChangeset for help on using the changeset viewer.