Changeset 7642 for main


Ignore:
Timestamp:
14 Feb 2012, 09:24:10 (13 years ago)
Author:
uli
Message:

Clean up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7641 r7642  
    2727from zope.component import queryUtility, getUtility, createObject
    2828from zope.formlib.textwidgets import BytesDisplayWidget
    29 #from hurry.query import Eq
    30 #from hurry.query.query import Query
    3129from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3230from waeup.sirp.accesscodes import (
     
    8583
    8684def emit_lock_message(view):
     85    """Flash a lock message.
     86    """
    8787    view.flash('The requested form is locked (read-only).')
    8888    view.redirect(view.url(view.context))
     
    9494    grok.context(IStudentsContainer)
    9595    title = 'Students'
    96     #grok.implements(IBreadcrumbIgnorable)
    9796
    9897    @property
    9998    def target(self):
    10099        user = get_current_principal()
    101         #import pdb; pdb.set_trace()
    102100        if getattr(user, 'user_type', None) == 'student':
    103101            return None
     
    226224            return
    227225        elif student_pw:
    228             self.flash('Password has already been set. You are using the wrong Access Code.')
     226            self.flash(
     227                'Password has already been set. You are using the '
     228                'wrong Access Code.')
    229229            return
    230230        # Mark pin as used (this also fires a pin related transition)
     
    237237            # Here we know that the ac is in state initialized so we do not
    238238            # expect an exception
    239             #import pdb; pdb.set_trace()
    240239            invalidate_accesscode(pin,comment)
    241240            IUserAccount(student).setPassword(self.ac_number)
     
    595594            return current_mode
    596595        return
    597        
     596
    598597    @property
    599598    def department(self):
     
    816815            self.flash('This level does not correspond current level.')
    817816        elif self.context.getStudent().state == REGISTERED:
    818             IWorkflowInfo(self.context.getStudent()).fireTransition('validate_courses')
     817            IWorkflowInfo(self.context.getStudent()).fireTransition(
     818                'validate_courses')
    819819            self.flash('Course list has been validated.')
    820820        else:
     
    929929        return
    930930
    931 # This manage form page is for both students and students officers.
    932931class PaymentsManageFormPage(SIRPEditFormPage):
    933932    """ Page to manage the student payments
     933
     934    This manage form page is for both students and students officers.
    934935    """
    935936    grok.context(IStudentPaymentsContainer)
     
    997998    label = 'Add online payment'
    998999    pnav = 4
    999    
     1000
    10001001    @action('Create ticket', style='primary')
    10011002    def createTicket(self, **data):
     
    10061007            'configuration'].accommodation_session:
    10071008                self.flash(
    1008                     'Your current session does not match accommodation session.')
     1009                    'Your current session does not match '
     1010                    'accommodation session.')
    10091011                self.redirect(self.url(self.context))
    10101012                return
     
    10311033        self.applyData(payment, **data)
    10321034        timestamp = "%d" % int(time()*1000)
    1033         #order_id = "%s%s" % (student_id[1:],timestamp)
    10341035        payment.p_id = "p%s" % timestamp
    10351036        payment.p_item = p_item
     
    10511052    grok.require('waeup.viewStudent')
    10521053    form_fields = grok.AutoFields(IStudentOnlinePayment)
    1053     form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    1054     form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1054    form_fields[
     1055        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1056    form_fields[
     1057        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    10551058    pnav = 4
    10561059
     
    11361139            self.context.getStudent(), studentview)
    11371140
    1138 # We don't need the display form page yet
    1139 #class AccommodationDisplayFormPage(SIRPDisplayFormPage):
    1140 #    """ Page to display the student accommodation data
    1141 #    """
    1142 #    grok.context(IStudentAccommodation)
    1143 #    grok.name('xxx')
    1144 #    grok.require('waeup.viewStudent')
    1145 #    form_fields = grok.AutoFields(IStudentAccommodation)
    1146 #    #grok.template('accommodationpage')
    1147 #    pnav = 4
    1148 
    1149 #    @property
    1150 #    def label(self):
    1151 #        return '%s: Accommodation Data' % self.context.__parent__.display_fullname
    1152 
    1153 # This manage form page is for both students and students officers.
     1141
    11541142class AccommodationManageFormPage(SIRPEditFormPage):
    11551143    """ Page to manage bed tickets.
     1144
     1145    This manage form page is for both students and students officers.
    11561146    """
    11571147    grok.context(IStudentAccommodation)
     
    12001190    @property
    12011191    def selected_actions(self):
    1202         sa = self.actions
    12031192        if getattr(self.request.principal, 'user_type', None) == 'student':
    1204             sa = [action for action in self.actions
    1205                   if not action.label in self.officers_only_actions]
    1206         return sa
     1193            return [action for action in self.actions
     1194                    if not action.label in self.officers_only_actions]
     1195        return self.actions
    12071196
    12081197class BedTicketAddPage(SIRPPage):
     
    12311220            self.redirect(self.url(self.context))
    12321221            return
    1233         if student['studycourse'].current_session != acc_details['booking_session']:
     1222        if student['studycourse'].current_session != acc_details[
     1223            'booking_session']:
    12341224            self.flash(
    12351225                'Your current session does not match accommodation session.')
     
    12371227            return
    12381228        if str(acc_details['booking_session']) in self.context.keys():
    1239             self.flash('You already booked a bed space in current accommodation session.')
     1229            self.flash(
     1230                'You already booked a bed space in current '
     1231                'accommodation session.')
    12401232            self.redirect(self.url(self.context))
    12411233            return
     
    12751267            return
    12761268        else:
    1277             comment = u"AC invalidated for %s" % self.context.getStudent().student_id
     1269            comment = u"AC invalidated for %s" % (
     1270                self.context.getStudent().student_id,)
    12781271            # Here we know that the ac is in state initialized so we do not
    12791272            # expect an exception, but the owner might be different
     
    13851378                self.redirect(self.url(self.context))
    13861379                return
    1387         # Rlease old bed if exists
     1380        # Release old bed if exists
    13881381        if self.context.bed != None:
    13891382            self.context.bed.owner = NOT_OCCUPIED
     
    14021395
    14031396    def render(self):
    1404         #self.redirect(self.url(self.context, '@@index'))
    14051397        return
    14061398
     
    15671559        return
    15681560
    1569     # To be specified in the customisation package
    15701561    def dataNotComplete(self):
    1571         #store = getUtility(IExtFileStore)
    1572         #if not store.getFileByContext(self.context, attr=u'xyz.jpg'):
    1573         #    return 'No xyz scan uploaded.'
     1562        """To be implemented in the customization package.
     1563        """
    15741564        return False
    15751565
     
    15771567    def requestClearance(self, **data):
    15781568        self.applyData(self.context, **data)
    1579         #self.context._p_changed = True
    15801569        if self.dataNotComplete():
    15811570            self.flash(self.dataNotComplete())
     
    16481637            return
    16491638        else:
    1650             comment = u"AC invalidated for %s" % self.context.getStudent().student_id
     1639            comment = u"AC invalidated for %s" % (
     1640                self.context.getStudent().student_id,)
    16511641            # Here we know that the ac is in state initialized so we do not
    16521642            # expect an exception, but the owner might be different
     
    17241714    @property
    17251715    def label(self):
    1726         return 'Add and remove course tickets of study level %s' % self.context.level_title
     1716        return 'Add and remove course tickets of study level %s' % (
     1717            self.context.level_title,)
    17271718
    17281719    @property
     
    17651756    @action('Register course list', style='primary')
    17661757    def RegisterCourses(self, **data):
    1767         IWorkflowInfo(self.context.getStudent()).fireTransition('register_courses')
     1758        IWorkflowInfo(self.context.getStudent()).fireTransition(
     1759            'register_courses')
    17681760        self.flash('Course list has been registered.')
    17691761        self.redirect(self.url(self.context))
     
    17871779    @action('Add course ticket')
    17881780    def addCourseTicket(self, **data):
    1789         # Double bottom ...
     1781        # Safety belt
    17901782        if self.context.getStudent().state != PAID:
    17911783            return
    17921784        ticket = CourseTicket()
    17931785        course = data['course']
     1786        for name in ['code', 'title', 'credits', 'passmark', 'semester']:
     1787            setattr(ticket, name, getattr(course, name))
    17941788        ticket.automatic = False
    1795         ticket.code = course.code
    1796         ticket.title = course.title
    17971789        ticket.faculty = course.__parent__.__parent__.__parent__.title
    17981790        ticket.department = course.__parent__.__parent__.title
    1799         ticket.credits = course.credits
    1800         ticket.passmark = course.passmark
    1801         ticket.semester = course.semester
    18021791        try:
    18031792            self.context.addCourseTicket(ticket)
Note: See TracChangeset for help on using the changeset viewer.