Ignore:
Timestamp:
20 Sep 2012, 08:49:37 (12 years ago)
Author:
uli
Message:

Merge changes from update branch (includes trunk changes until r9107).

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

Legend:

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

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

    r8736 r9209  
    1 ## $Id$
     13## $Id$
    22##
    33## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
     
    150150
    151151class ContactActionButton(ManageActionButton):
    152     grok.order(4)
     152    grok.order(5)
    153153    grok.context(IStudent)
    154154    grok.view(StudentBaseDisplayFormPage)
     
    165165    text = _('Manage')
    166166    target = 'manage_base'
     167
     168class AdmissionSlipActionButton(ManageActionButton):
     169    grok.order(4)
     170    grok.context(IStudent)
     171    grok.view(StudentBaseDisplayFormPage)
     172    grok.require('waeup.viewStudent')
     173    icon = 'actionicon_pdf.png'
     174    text = _('Download admission letter')
     175    target = 'admission_slip.pdf'
     176
     177class StudentTransfernButton(ManageActionButton):
     178    grok.order(6)
     179    grok.context(IStudent)
     180    grok.view(StudentBaseDisplayFormPage)
     181    grok.require('waeup.manageStudent')
     182    text = _('Transfer student')
     183    target = 'transfer'
     184    icon = 'actionicon_redo.png'
     185
     186class StudentDeactivateActionButton(ManageActionButton):
     187    grok.order(7)
     188    grok.context(IStudent)
     189    grok.view(StudentBaseDisplayFormPage)
     190    grok.require('waeup.manageStudent')
     191    text = _('Deactivate account')
     192    target = 'deactivate'
     193    icon = 'actionicon_traffic_lights_red.png'
     194
     195    @property
     196    def target_url(self):
     197        if self.context.suspended:
     198            return ''
     199        return self.view.url(self.view.context, self.target)
     200
     201    @property
     202    def onclick(self):
     203        return "return window.confirm(%s);" % _(
     204            "'A history message will be added. Are you sure?'")
     205
     206class StudentActivateActionButton(ManageActionButton):
     207    grok.order(7)
     208    grok.context(IStudent)
     209    grok.view(StudentBaseDisplayFormPage)
     210    grok.require('waeup.manageStudent')
     211    text = _('Activate account')
     212    target = 'activate'
     213    icon = 'actionicon_traffic_lights_green.png'
     214
     215    @property
     216    def target_url(self):
     217        if not self.context.suspended:
     218            return ''
     219        return self.view.url(self.view.context, self.target)
     220
     221    @property
     222    def onclick(self):
     223        return "return window.confirm(%s);" % _(
     224            "'A history message will be added. Are you sure?'")
    167225
    168226class StudentClearanceManageActionButton(ManageActionButton):
     
    231289    target = 'view_personal'
    232290
     291class StudentPersonalManageActionButton(ManageActionButton):
     292    grok.order(1)
     293    grok.context(IStudent)
     294    grok.view(StudentPersonalDisplayFormPage)
     295    grok.require('waeup.manageStudent')
     296    text = _('Manage')
     297    target = 'manage_personal'
     298
    233299class StudentPersonalEditActionButton(ManageActionButton):
    234     grok.order(1)
     300    grok.order(2)
    235301    grok.context(IStudent)
    236302    grok.view(StudentPersonalDisplayFormPage)
    237     grok.require('waeup.viewStudent')
     303    grok.require('waeup.handleStudent')
    238304    text = _('Edit')
    239305    target = 'edit_personal'
     
    247313    target = 'manage'
    248314
     315    @property
     316    def target_url(self):
     317        if self.context.is_current:
     318            return self.view.url(self.view.context, self.target)
     319        return False
     320
    249321class StudyLevelManageActionButton(ManageActionButton):
    250322    grok.order(1)
     
    254326    text = _('Manage')
    255327    target = 'manage'
     328
     329    @property
     330    def target_url(self):
     331        is_current = self.context.__parent__.is_current
     332        if not is_current:
     333            return ''
     334        return self.view.url(self.view.context, self.target)
    256335
    257336class StudentValidateCoursesActionButton(ManageActionButton):
     
    266345    @property
    267346    def target_url(self):
     347        is_current = self.context.__parent__.is_current
    268348        if self.context.student.state != REGISTERED or \
    269             str(self.context.__parent__.current_level) != self.context.__name__:
     349            str(self.context.__parent__.current_level) != self.context.__name__ or\
     350            not is_current:
    270351            return ''
    271352        return self.view.url(self.view.context, self.target)
     
    282363    @property
    283364    def target_url(self):
     365        is_current = self.context.__parent__.is_current
    284366        if self.context.student.state not in (VALIDATED, REGISTERED) or \
    285             str(self.context.__parent__.current_level) != self.context.__name__:
     367            str(self.context.__parent__.current_level) != self.context.__name__ or\
     368            not is_current:
    286369            return ''
    287370        return self.view.url(self.view.context, self.target)
     
    296379    target = 'course_registration.pdf'
    297380
     381    @property
     382    def target_url(self):
     383        is_current = self.context.__parent__.is_current
     384        if not is_current:
     385            return ''
     386        return self.view.url(self.view.context, self.target)
     387
    298388class CourseTicketManageActionButton(ManageActionButton):
    299389    grok.order(1)
     
    313403
    314404class PaymentReceiptActionButton(ManageActionButton):
    315     grok.order(1)
     405    grok.order(9) # This button should always be the last one.
    316406    grok.context(IStudentOnlinePayment)
    317407    grok.view(OnlinePaymentDisplayFormPage)
     
    327417        return self.view.url(self.view.context, self.target)
    328418
    329 
    330419class ApprovePaymentActionButton(ManageActionButton):
    331     grok.order(2)
     420    grok.order(8)
    332421    grok.context(IStudentOnlinePayment)
    333422    grok.view(OnlinePaymentDisplayFormPage)
     
    437526    grok.require('waeup.handleStudent')
    438527    icon = 'actionicon_start.gif'
    439     text = _('Start session')
     528    text = _('Start new session')
    440529    target = 'start_session'
    441530
    442531    @property
    443532    def target_url(self):
    444         if self.context.next_session_allowed:
     533        if self.context.next_session_allowed and self.context.is_current:
    445534            return self.view.url(self.view.context, self.target)
    446535        return False
     
    460549        condition2 = str(student['studycourse'].current_level) in \
    461550            self.view.context.keys()
    462         if condition1 or condition2:
     551        condition3 = not self.context.is_current
     552        if condition1 or condition2 or condition3:
    463553            return ''
    464554        return self.view.url(self.view.context, self.target)
     
    469559    grok.view(StudyLevelDisplayFormPage)
    470560    grok.require('waeup.handleStudent')
    471     text = _('Add and remove courses')
     561    text = _('Edit course list')
    472562    target = 'edit'
    473563
     
    478568        condition2 = student[
    479569            'studycourse'].current_level != self.view.context.level
    480         if condition1 or condition2:
     570        is_current = self.context.__parent__.is_current
     571        if condition1 or condition2 or not is_current:
    481572            return ''
    482573        return self.view.url(self.view.context, self.target)
     
    542633    @property
    543634    def targets(self):
    544         student_url = self.view.application_url() + (
    545             '/students/%s' % self.request.principal.id)
    546         #app_slip = getUtility(IExtFileStore).getFileByContext(
    547         #    self.context.student, 'application_slip')
     635        student = grok.getSite()['students'][self.request.principal.id]
     636        student_url = self.view.url(student)
     637        app_slip = getUtility(IExtFileStore).getFileByContext(
     638            student, 'application_slip')
    548639        targets = []
    549         #if app_slip:
    550         #    targets = [{'url':student_url + '/application_slip', 'title':'Application Slip'},]
     640        if app_slip:
     641            targets = [{'url':student_url + '/application_slip', 'title':'Application Slip'},]
    551642        targets += [
    552643            {'url':student_url, 'title':'Base Data'},
Note: See TracChangeset for help on using the changeset viewer.