- Timestamp:
- 11 Jun 2016, 13:59:58 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/viewlets.py
r13913 r13915 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 28 StudentsContainerPage, … … 42 39 IStudentPaymentsContainer, IStudentsUtils 43 40 ) 41 from waeup.kofa.students.workflow import ( 42 ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, 43 VALIDATED, GRADUATED, TRANSCRIPT) 44 44 from waeup.kofa.university.interfaces import ICourse 45 45 46 grok.context(IKofaObject) # Make IKofaObject the default context 46 47 grok.context(IKofaObject) # Make IKofaObject the default context 47 48 grok.templatedir('browser_templates') 48 49 … … 50 51 class StudentManageSidebar(grok.ViewletManager): 51 52 grok.name('left_studentmanage') 53 52 54 53 55 class StudentManageLink(grok.Viewlet): … … 70 72 # Here we know that the cookie has been set 71 73 lang = self.request.cookies.get('kofa.language') 72 text = translate( self.text, 'waeup.kofa',73 target_language=lang)74 text = translate( 75 self.text, 'waeup.kofa', target_language=lang) 74 76 if not self.link: 75 77 return '' 76 78 return u'<li><a href="%s">%s</a></li>' % ( 77 url, text) 79 url, text) 80 78 81 79 82 class StudentManageApplicationLink(StudentManageLink): … … 87 90 if slip: 88 91 lang = self.request.cookies.get('kofa.language') 89 text = translate( self.text, 'waeup.kofa',90 target_language=lang)91 url = self.view.url(self.context.student, self.link)92 text = translate( 93 self.text, 'waeup.kofa', target_language=lang) 94 url = self.view.url(self.context.student, self.link) 92 95 return u'<li><a href="%s">%s</a></li>' % ( 93 96 url, text) 94 97 return '' 98 95 99 96 100 class StudentManageBaseLink(StudentManageLink): … … 98 102 link = 'index' 99 103 text = _(u'Base Data') 104 100 105 101 106 class StudentManageClearanceLink(StudentManageLink): … … 105 110 text = _(u'Clearance Data') 106 111 112 107 113 class StudentManagePersonalLink(StudentManageLink): 108 114 grok.order(4) … … 111 117 text = _(u'Personal Data') 112 118 119 113 120 class StudentManageStudyCourseLink(StudentManageLink): 114 121 grok.order(5) 115 122 link = 'studycourse' 116 123 text = _(u'Study Course') 124 117 125 118 126 class StudentManagePaymentsLink(StudentManageLink): … … 121 129 link = 'payments' 122 130 text = _(u'Payments') 131 123 132 124 133 class StudentManageAccommodationLink(StudentManageLink): … … 129 138 text = _(u'Accommodation') 130 139 140 131 141 class StudentManageHistoryLink(StudentManageLink): 132 142 grok.order(8) … … 142 152 text = _('Manage students section') 143 153 154 144 155 class StudentsContainerAddActionButton(AddActionButton): 145 156 grok.order(1) … … 149 160 text = _('Add student') 150 161 target = 'addstudent' 162 151 163 152 164 class ContactActionButton(ManageActionButton): … … 159 171 target = 'contactstudent' 160 172 173 161 174 class StudentBaseManageActionButton(ManageActionButton): 162 175 grok.order(1) … … 166 179 text = _('Manage') 167 180 target = 'manage_base' 181 168 182 169 183 class StudentTrigTransActionButton(ManageActionButton): … … 176 190 target = 'trigtrans' 177 191 192 178 193 class StudentLoginAsActionButton(ManageActionButton): 179 194 grok.order(3) … … 185 200 target = 'loginasstep1' 186 201 202 187 203 class AdmissionSlipActionButton(ManageActionButton): 188 204 grok.order(4) … … 194 210 target = 'admission_slip.pdf' 195 211 212 196 213 class StudentTransferButton(ManageActionButton): 197 214 grok.order(6) … … 203 220 icon = 'actionicon_redo.png' 204 221 222 205 223 class StudentDeactivateActionButton(ManageActionButton): 206 224 grok.order(7) … … 223 241 "'A history message will be added. Are you sure?'") 224 242 243 225 244 class StudentActivateActionButton(ManageActionButton): 226 245 grok.order(7) … … 243 262 "'A history message will be added. Are you sure?'") 244 263 264 245 265 class StudentClearanceManageActionButton(ManageActionButton): 246 266 grok.order(1) … … 250 270 text = _('Manage') 251 271 target = 'manage_clearance' 272 252 273 253 274 class StudentClearActionButton(ManageActionButton): … … 262 283 @property 263 284 def target_url(self): 264 cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context) 285 cdm = getUtility( 286 IStudentsUtils).clearance_disabled_message(self.context) 265 287 if cdm: 266 288 return '' … … 268 290 return '' 269 291 return self.view.url(self.view.context, self.target) 292 270 293 271 294 class StudentRejectClearanceActionButton(ManageActionButton): … … 280 303 @property 281 304 def target_url(self): 282 cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context) 305 cdm = getUtility( 306 IStudentsUtils).clearance_disabled_message(self.context) 283 307 if cdm: 284 308 return '' … … 286 310 return '' 287 311 return self.view.url(self.view.context, self.target) 312 288 313 289 314 class ClearanceSlipActionButton(ManageActionButton): … … 296 321 target = 'clearance_slip.pdf' 297 322 323 298 324 class ClearanceViewActionButton(ManageActionButton): 299 325 grok.order(1) … … 305 331 target = 'view_clearance' 306 332 333 307 334 class PersonalViewActionButton(ManageActionButton): 308 335 grok.order(1) … … 314 341 target = 'view_personal' 315 342 343 316 344 class StudentPersonalManageActionButton(ManageActionButton): 317 345 grok.order(1) … … 322 350 target = 'manage_personal' 323 351 352 324 353 class StudentPersonalEditActionButton(ManageActionButton): 325 354 grok.order(2) … … 329 358 text = _('Edit') 330 359 target = 'edit_personal' 360 331 361 332 362 class StudyCourseManageActionButton(ManageActionButton): … … 343 373 return self.view.url(self.view.context, self.target) 344 374 return False 375 345 376 346 377 class StudyCourseTranscriptActionButton(ManageActionButton): … … 359 390 return False 360 391 392 361 393 class TranscriptSlipActionButton(ManageActionButton): 362 394 grok.order(1) … … 374 406 return False 375 407 408 376 409 class RevertTransferActionButton(ManageActionButton): 377 410 grok.order(1) … … 389 422 return False 390 423 424 391 425 class StudyLevelManageActionButton(ManageActionButton): 392 426 grok.order(1) … … 403 437 return '' 404 438 return self.view.url(self.view.context, self.target) 439 405 440 406 441 class StudentValidateCoursesActionButton(ManageActionButton): … … 415 450 @property 416 451 def target_url(self): 417 is_current = self.context.__parent__.is_current 418 if self.context.student.state != REGISTERED or \ 419 str(self.context.__parent__.current_level) != self.context.__name__ or\ 420 not is_current: 421 return '' 422 return self.view.url(self.view.context, self.target) 452 if not self.context.__parent__.is_current: 453 return '' 454 if self.context.student.state != REGISTERED: 455 return '' 456 if str(self.context.__parent__.current_level) != self.context.__name__: 457 return '' 458 return self.view.url(self.view.context, self.target) 459 423 460 424 461 class StudentRejectCoursesActionButton(ManageActionButton): … … 433 470 @property 434 471 def target_url(self): 435 is_current = self.context.__parent__.is_current 436 if self.context.student.state not in (VALIDATED, REGISTERED) or \ 437 str(self.context.__parent__.current_level) != self.context.__name__ or\ 438 not is_current: 439 return '' 440 return self.view.url(self.view.context, self.target) 472 if not self.context.__parent__.is_current: 473 return '' 474 if self.context.student.state not in (VALIDATED, REGISTERED): 475 return '' 476 if str(self.context.__parent__.current_level) != self.context.__name__: 477 return '' 478 return self.view.url(self.view.context, self.target) 479 441 480 442 481 class StudentUnregisterCoursesActionButton(ManageActionButton): … … 451 490 @property 452 491 def target_url(self): 453 is_current = self.context.__parent__.is_current 454 if self.context.student.state != REGISTERED or \ 455 str(self.context.__parent__.current_level) != self.context.__name__ or\ 456 not is_current: 457 return '' 458 return self.view.url(self.view.context, self.target) 492 if not self.context.__parent__.is_current: 493 return '' 494 if self.context.student.state != REGISTERED: 495 return '' 496 if str(self.context.__parent__.current_level) != self.context.__name__: 497 return '' 498 return self.view.url(self.view.context, self.target) 499 459 500 460 501 class CourseRegistrationSlipActionButton(ManageActionButton): … … 474 515 return self.view.url(self.view.context, self.target) 475 516 517 476 518 class CourseTicketManageActionButton(ManageActionButton): 477 519 grok.order(1) … … 482 524 target = 'manage' 483 525 484 #class OnlinePaymentManageActionButton(ManageActionButton):485 # grok.order(1)486 # grok.context(IStudentPaymentsContainer)487 # grok.view(PaymentsDisplayFormPage)488 # grok.require('waeup.manageStudent')489 # text = 'Manage payments'490 # target = 'manage'491 526 492 527 class PaymentReceiptActionButton(ManageActionButton): 493 grok.order(9) # This button should always be the last one.528 grok.order(9) # This button should always be the last one. 494 529 grok.context(IStudentOnlinePayment) 495 530 grok.view(OnlinePaymentDisplayFormPage) … … 504 539 # return '' 505 540 return self.view.url(self.view.context, self.target) 541 506 542 507 543 class ApprovePaymentActionButton(ManageActionButton): … … 520 556 return self.view.url(self.view.context, self.target) 521 557 558 522 559 class BedTicketSlipActionButton(ManageActionButton): 523 560 grok.order(1) … … 529 566 target = 'bed_allocation_slip.pdf' 530 567 568 531 569 class RelocateStudentActionButton(ManageActionButton): 532 570 grok.order(2) … … 538 576 target = 'relocate' 539 577 578 540 579 class StudentBaseActionButton(ManageActionButton): 541 580 grok.order(1) … … 545 584 text = _('Edit') 546 585 target = 'edit_base' 586 547 587 548 588 class StudentPasswordActionButton(ManageActionButton): … … 555 595 target = 'change_password' 556 596 597 557 598 class StudentPassportActionButton(ManageActionButton): 558 599 grok.order(3) … … 566 607 @property 567 608 def target_url(self): 568 PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES 609 PORTRAIT_CHANGE_STATES = getUtility( 610 IStudentsUtils).PORTRAIT_CHANGE_STATES 569 611 if self.context.state not in PORTRAIT_CHANGE_STATES: 570 612 return '' 571 613 return self.view.url(self.view.context, self.target) 614 572 615 573 616 class StudentClearanceStartActionButton(ManageActionButton): … … 586 629 return self.view.url(self.view.context, self.target) 587 630 631 588 632 class StudentClearanceEditActionButton(ManageActionButton): 589 633 grok.order(1) … … 599 643 return '' 600 644 return self.view.url(self.view.context, self.target) 645 601 646 602 647 class StartSessionActionButton(ManageActionButton): … … 614 659 return self.view.url(self.view.context, self.target) 615 660 return False 661 616 662 617 663 class AddStudyLevelActionButton(AddActionButton): … … 633 679 return '' 634 680 return self.view.url(self.view.context, self.target) 681 635 682 636 683 class StudyLevelEditActionButton(ManageActionButton): … … 652 699 return '' 653 700 701 654 702 class AddPaymentActionButton(AddActionButton): 655 703 grok.order(1) … … 659 707 text = _('Add current session payment ticket') 660 708 target = 'addop' 709 661 710 662 711 class AddPreviousPaymentActionButton(AddActionButton): … … 676 725 return self.view.url(self.view.context, self.target) 677 726 727 678 728 class AddBalancePaymentActionButton(AddActionButton): 679 729 grok.order(3) … … 691 741 return self.view.url(self.view.context, self.target) 692 742 743 693 744 class RequestTranscriptActionButton(ManageActionButton): 694 745 grok.order(8) … … 705 756 return '' 706 757 return self.view.url(self.view.context, self.target) 758 707 759 708 760 class ProcessTranscriptRequestActionButton(ManageActionButton): … … 721 773 return self.view.url(self.view.context, self.target) 722 774 775 723 776 class StudentsTab(PrimaryNavTab): 724 777 """Students tab in primary navigation. 725 778 """ 726 727 779 grok.context(IKofaObject) 728 780 grok.order(4) … … 737 789 return self.view.application_url('students') 738 790 791 739 792 class PrimaryStudentNavManager(grok.ViewletManager): 740 793 """Viewlet manager for the primary navigation tab. 741 794 """ 742 795 grok.name('primary_nav_student') 796 743 797 744 798 class PrimaryStudentNavTab(grok.Viewlet): … … 764 818 return 'active' 765 819 return '' 820 766 821 767 822 class MyStudentDataTab(PrimaryStudentNavTab): … … 790 845 targets = [] 791 846 if app_slip: 792 targets = [{'url': student_url + '/application_slip',793 'title': _('Application Slip')},]847 targets = [{'url': student_url + '/application_slip', 848 'title': _('Application Slip')}, ] 794 849 targets += [ 795 {'url':student_url, 'title':'Base Data'}, 796 {'url':student_url + '/view_clearance', 797 'title':_('Clearance Data')}, 798 {'url':student_url + '/view_personal', 'title':_('Personal Data')}, 799 {'url':student_url + '/studycourse', 'title':_('Study Course')}, 800 {'url':student_url + '/payments', 'title':_('Payments')}, 801 {'url':student_url + '/accommodation', 802 'title':_('Accommodation Data')}, 803 {'url':student_url + '/history', 'title':_('History')}, 850 {'url': student_url, 'title': 'Base Data'}, 851 {'url': student_url + '/view_clearance', 852 'title': _('Clearance Data')}, 853 {'url': student_url + '/view_personal', 854 'title': _('Personal Data')}, 855 {'url': student_url + '/studycourse', 'title': _('Study Course')}, 856 {'url': student_url + '/payments', 'title': _('Payments')}, 857 {'url': student_url + '/accommodation', 858 'title': _('Accommodation Data')}, 859 {'url': student_url + '/history', 'title': _('History')}, 804 860 ] 805 861 return targets 862 806 863 807 864 class DownloadCSVFileActionButton(ManageActionButton): … … 817 874 grok.order(1) 818 875 876 819 877 class DownloadTicketOverviewActionButton(ManageActionButton): 820 878 """ 'Download ticket overview' button for courses.
Note: See TracChangeset for help on using the changeset viewer.