Ignore:
Timestamp:
10 Sep 2012, 11:05:07 (12 years ago)
Author:
uli
Message:

Merge changes from trunk, r8786-HEAD

Location:
main/waeup.kofa/branches/uli-async-update
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-async-update

  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/viewlets.py

    r8736 r9169  
    1 ## $Id$
     13## $Id$
    22##
    33## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
     
    166166    target = 'manage_base'
    167167
     168class StudentTransfernButton(ManageActionButton):
     169    grok.order(5)
     170    grok.context(IStudent)
     171    grok.view(StudentBaseDisplayFormPage)
     172    grok.require('waeup.manageStudent')
     173    text = _('Transfer student')
     174    target = 'transfer'
     175    icon = 'actionicon_redo.png'
     176
     177class StudentDeactivateActionButton(ManageActionButton):
     178    grok.order(6)
     179    grok.context(IStudent)
     180    grok.view(StudentBaseDisplayFormPage)
     181    grok.require('waeup.manageStudent')
     182    text = _('Deactivate account')
     183    target = 'deactivate'
     184    icon = 'actionicon_traffic_lights_red.png'
     185
     186    @property
     187    def target_url(self):
     188        if self.context.suspended:
     189            return ''
     190        return self.view.url(self.view.context, self.target)
     191
     192    @property
     193    def onclick(self):
     194        return "return window.confirm(%s);" % _(
     195            "'A history message will be added. Are you sure?'")
     196
     197class StudentActivateActionButton(ManageActionButton):
     198    grok.order(6)
     199    grok.context(IStudent)
     200    grok.view(StudentBaseDisplayFormPage)
     201    grok.require('waeup.manageStudent')
     202    text = _('Activate account')
     203    target = 'activate'
     204    icon = 'actionicon_traffic_lights_green.png'
     205
     206    @property
     207    def target_url(self):
     208        if not self.context.suspended:
     209            return ''
     210        return self.view.url(self.view.context, self.target)
     211
     212    @property
     213    def onclick(self):
     214        return "return window.confirm(%s);" % _(
     215            "'A history message will be added. Are you sure?'")
     216
    168217class StudentClearanceManageActionButton(ManageActionButton):
    169218    grok.order(1)
     
    231280    target = 'view_personal'
    232281
     282class StudentPersonalManageActionButton(ManageActionButton):
     283    grok.order(1)
     284    grok.context(IStudent)
     285    grok.view(StudentPersonalDisplayFormPage)
     286    grok.require('waeup.manageStudent')
     287    text = _('Manage')
     288    target = 'manage_personal'
     289
    233290class StudentPersonalEditActionButton(ManageActionButton):
    234     grok.order(1)
     291    grok.order(2)
    235292    grok.context(IStudent)
    236293    grok.view(StudentPersonalDisplayFormPage)
    237     grok.require('waeup.viewStudent')
     294    grok.require('waeup.handleStudent')
    238295    text = _('Edit')
    239296    target = 'edit_personal'
     
    247304    target = 'manage'
    248305
     306    @property
     307    def target_url(self):
     308        if self.context.is_current:
     309            return self.view.url(self.view.context, self.target)
     310        return False
     311
    249312class StudyLevelManageActionButton(ManageActionButton):
    250313    grok.order(1)
     
    254317    text = _('Manage')
    255318    target = 'manage'
     319
     320    @property
     321    def target_url(self):
     322        is_current = self.context.__parent__.is_current
     323        if not is_current:
     324            return ''
     325        return self.view.url(self.view.context, self.target)
    256326
    257327class StudentValidateCoursesActionButton(ManageActionButton):
     
    266336    @property
    267337    def target_url(self):
     338        is_current = self.context.__parent__.is_current
    268339        if self.context.student.state != REGISTERED or \
    269             str(self.context.__parent__.current_level) != self.context.__name__:
     340            str(self.context.__parent__.current_level) != self.context.__name__ or\
     341            not is_current:
    270342            return ''
    271343        return self.view.url(self.view.context, self.target)
     
    282354    @property
    283355    def target_url(self):
     356        is_current = self.context.__parent__.is_current
    284357        if self.context.student.state not in (VALIDATED, REGISTERED) or \
    285             str(self.context.__parent__.current_level) != self.context.__name__:
     358            str(self.context.__parent__.current_level) != self.context.__name__ or\
     359            not is_current:
    286360            return ''
    287361        return self.view.url(self.view.context, self.target)
     
    296370    target = 'course_registration.pdf'
    297371
     372    @property
     373    def target_url(self):
     374        is_current = self.context.__parent__.is_current
     375        if not is_current:
     376            return ''
     377        return self.view.url(self.view.context, self.target)
     378
    298379class CourseTicketManageActionButton(ManageActionButton):
    299380    grok.order(1)
     
    313394
    314395class PaymentReceiptActionButton(ManageActionButton):
    315     grok.order(1)
     396    grok.order(9) # This button should always be the last one.
    316397    grok.context(IStudentOnlinePayment)
    317398    grok.view(OnlinePaymentDisplayFormPage)
     
    327408        return self.view.url(self.view.context, self.target)
    328409
    329 
    330410class ApprovePaymentActionButton(ManageActionButton):
    331     grok.order(2)
     411    grok.order(8)
    332412    grok.context(IStudentOnlinePayment)
    333413    grok.view(OnlinePaymentDisplayFormPage)
     
    437517    grok.require('waeup.handleStudent')
    438518    icon = 'actionicon_start.gif'
    439     text = _('Start session')
     519    text = _('Start new session')
    440520    target = 'start_session'
    441521
    442522    @property
    443523    def target_url(self):
    444         if self.context.next_session_allowed:
     524        if self.context.next_session_allowed and self.context.is_current:
    445525            return self.view.url(self.view.context, self.target)
    446526        return False
     
    460540        condition2 = str(student['studycourse'].current_level) in \
    461541            self.view.context.keys()
    462         if condition1 or condition2:
     542        condition3 = not self.context.is_current
     543        if condition1 or condition2 or condition3:
    463544            return ''
    464545        return self.view.url(self.view.context, self.target)
     
    469550    grok.view(StudyLevelDisplayFormPage)
    470551    grok.require('waeup.handleStudent')
    471     text = _('Add and remove courses')
     552    text = _('Edit course list')
    472553    target = 'edit'
    473554
     
    478559        condition2 = student[
    479560            'studycourse'].current_level != self.view.context.level
    480         if condition1 or condition2:
     561        is_current = self.context.__parent__.is_current
     562        if condition1 or condition2 or not is_current:
    481563            return ''
    482564        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.