Ignore:
Timestamp:
17 Jun 2012, 07:09:21 (13 years ago)
Author:
Henrik Bettermann
Message:

Replace getStudent method by a 'student' attribute.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py

    r8548 r8736  
    282282        """
    283283        if IStudentNavigation.providedBy(self.context):
    284             return self.context.getStudent().display_fullname
     284            return self.context.student.display_fullname
    285285        return
    286286
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/staffsitelayout.pt

    r8458 r8736  
    6161        tal:condition="layout/getStudentName" class="wfstatus">
    6262          <span i18n:translate="">Student Id:</span>
    63           <span tal:replace="python:context.getStudent().student_id">
     63          <span tal:replace="python:context.student.student_id">
    6464            ID
    6565          </span>&nbsp;&nbsp;
    6666          <span i18n:translate="">State:</span>
    67           <span tal:replace="python:context.getStudent().translated_state">
     67          <span tal:replace="python:context.student.translated_state">
    6868            STATE
    6969          </span>
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/studentsitelayout.pt

    r8458 r8736  
    6464              tal:content="structure provider:breadcrumbs" />
    6565        <span tal:condition="layout/getStudentName" class="wfstatus">
    66             <span tal:replace="python:context.getStudent().student_id">
     66            <span tal:replace="python:context.student.student_id">
    6767              Id
    6868            </span>
    6969            |
    70             <span tal:replace="python:context.getStudent().translated_state">
     70            <span tal:replace="python:context.student.translated_state">
    7171              State
    7272            </span>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py

    r8735 r8736  
    4848        return
    4949
    50     def getStudent(self):
     50    @property
     51    def student(self):
    5152        return self.__parent__
    5253
     
    6970        return
    7071
    71     def getStudent(self):
    72         return self.__parent__.__parent__
     72    @property
     73    def student(self):
     74        try:
     75            return self.__parent__.__parent__
     76        except AttributeError:
     77            return None
    7378
    7479    def writeLogMessage(self, view, message):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r8626 r8736  
    650650            return 'Current session does not correspond.'
    651651        # Check if student is in state REGISTERED
    652         if obj.getStudent().state != VALIDATED:
     652        if obj.student.state != VALIDATED:
    653653            return 'Student in wrong state.'
    654654        return None
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8735 r8736  
    431431
    432432    def render(self):
    433         studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     433        studentview = StudentBaseDisplayFormPage(self.context.student,
    434434            self.request)
    435435        students_utils = getUtility(IStudentsUtils)
    436436        return students_utils.renderPDF(
    437437            self, 'clearance.pdf',
    438             self.context.getStudent(), studentview)
     438            self.context.student, studentview)
    439439
    440440class StudentClearanceManageFormPage(KofaEditFormPage):
     
    700700            target_language=lang)
    701701        return _('${a}: Study Level ${b}', mapping = {
    702             'a':self.context.getStudent().display_fullname,
     702            'a':self.context.student.display_fullname,
    703703            'b':level_title})
    704704
     
    751751        Mand = translate(_('Mand.'), 'waeup.kofa', target_language=portal_language)
    752752        Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
    753         studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     753        studentview = StudentBaseDisplayFormPage(self.context.student,
    754754            self.request)
    755755        students_utils = getUtility(IStudentsUtils)
     
    758758        return students_utils.renderPDF(
    759759            self, 'course_registration.pdf',
    760             self.context.getStudent(), studentview,
     760            self.context.student, studentview,
    761761            tableheader=[(Sem,'semester', 1.5),(Code,'code', 2.5),
    762762                         (Title,'title', 5),
     
    843843        if str(self.context.__parent__.current_level) != self.context.__name__:
    844844            self.flash(_('This level does not correspond current level.'))
    845         elif self.context.getStudent().state == REGISTERED:
    846             IWorkflowInfo(self.context.getStudent()).fireTransition(
     845        elif self.context.student.state == REGISTERED:
     846            IWorkflowInfo(self.context.student).fireTransition(
    847847                'validate_courses')
    848848            self.flash(_('Course list has been validated.'))
     
    867867            self.redirect(self.url(self.context))
    868868            return
    869         elif self.context.getStudent().state == VALIDATED:
    870             IWorkflowInfo(self.context.getStudent()).fireTransition('reset8')
     869        elif self.context.student.state == VALIDATED:
     870            IWorkflowInfo(self.context.student).fireTransition('reset8')
    871871            message = _('Course list request has been annulled.')
    872872            self.flash(message)
    873         elif self.context.getStudent().state == REGISTERED:
    874             IWorkflowInfo(self.context.getStudent()).fireTransition('reset7')
     873        elif self.context.student.state == REGISTERED:
     874            IWorkflowInfo(self.context.student).fireTransition('reset7')
    875875            message = _('Course list request has been rejected:')
    876876            self.flash(message)
     
    880880            return
    881881        args = {'subject':message}
    882         self.redirect(self.url(self.context.getStudent()) +
     882        self.redirect(self.url(self.context.student) +
    883883            '/contactstudent?%s' % urlencode(args))
    884884        return
     
    938938    def label(self):
    939939        return _('${a}: Course Ticket ${b}', mapping = {
    940             'a':self.context.getStudent().display_fullname,
     940            'a':self.context.student.display_fullname,
    941941            'b':self.context.code})
    942942
     
    10681068    def label(self):
    10691069        return _('${a}: Online Payment Ticket ${b}', mapping = {
    1070             'a':self.context.getStudent().display_fullname,
     1070            'a':self.context.student.display_fullname,
    10711071            'b':self.context.p_id})
    10721072
     
    11291129        #    self.redirect(self.url(self.context))
    11301130        #    return
    1131         studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     1131        studentview = StudentBaseDisplayFormPage(self.context.student,
    11321132            self.request)
    11331133        students_utils = getUtility(IStudentsUtils)
    11341134        return students_utils.renderPDF(self, 'payment_slip.pdf',
    1135             self.context.getStudent(), studentview, note=self.note)
     1135            self.context.student, studentview, note=self.note)
    11361136
    11371137
     
    12081208
    12091209    def update(self, SUBMIT=None):
    1210         student = self.context.getStudent()
     1210        student = self.context.student
    12111211        students_utils = getUtility(IStudentsUtils)
    12121212        acc_details  = students_utils.getAccommodationDetails(student)
     
    12851285            # expect an exception, but the owner might be different
    12861286            if not invalidate_accesscode(
    1287                 pin,comment,self.context.getStudent().student_id):
     1287                pin,comment,self.context.student.student_id):
    12881288                self.flash(_('You are not the owner of this access code.'))
    12891289                return
     
    13491349
    13501350    def render(self):
    1351         studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     1351        studentview = StudentBaseDisplayFormPage(self.context.student,
    13521352            self.request)
    13531353        students_utils = getUtility(IStudentsUtils)
    13541354        return students_utils.renderPDF(
    13551355            self, 'bed_allocation.pdf',
    1356             self.context.getStudent(), studentview)
     1356            self.context.student, studentview)
    13571357
    13581358class BedTicketRelocationPage(UtilityView, grok.View):
     
    13661366    # of the bed has changed
    13671367    def update(self):
    1368         student = self.context.getStudent()
     1368        student = self.context.student
    13691369        students_utils = getUtility(IStudentsUtils)
    13701370        acc_details  = students_utils.getAccommodationDetails(student)
     
    14961496
    14971497    def update(self):
    1498         if self.context.getStudent().state != ADMITTED:
     1498        if self.context.student.state != ADMITTED:
    14991499            emit_lock_message(self)
    15001500            return
     
    16761676            # expect an error, but the owner might be different
    16771677            if not invalidate_accesscode(
    1678                 pin,comment,self.context.getStudent().student_id):
     1678                pin,comment,self.context.student.student_id):
    16791679                self.flash(_('You are not the owner of this access code.'))
    16801680                return
    1681         if self.context.getStudent().state == CLEARED:
    1682             IWorkflowInfo(self.context.getStudent()).fireTransition(
     1681        if self.context.student.state == CLEARED:
     1682            IWorkflowInfo(self.context.student).fireTransition(
    16831683                'pay_first_school_fee')
    1684         elif self.context.getStudent().state == RETURNING:
    1685             IWorkflowInfo(self.context.getStudent()).fireTransition(
     1684        elif self.context.student.state == RETURNING:
     1685            IWorkflowInfo(self.context.student).fireTransition(
    16861686                'pay_school_fee')
    1687         elif self.context.getStudent().state == PAID:
    1688             IWorkflowInfo(self.context.getStudent()).fireTransition(
     1687        elif self.context.student.state == PAID:
     1688            IWorkflowInfo(self.context.student).fireTransition(
    16891689                'pay_pg_fee')
    16901690        self.flash(_('Session started.'))
     
    17101710
    17111711    def update(self):
    1712         if self.context.getStudent().state != PAID:
     1712        if self.context.student.state != PAID:
    17131713            emit_lock_message(self)
    17141714            return
     
    17421742
    17431743    def update(self):
    1744         if self.context.getStudent().state != PAID:
     1744        if self.context.student.state != PAID:
    17451745            emit_lock_message(self)
    17461746            return
     
    17991799                mapping = {'a':self.max_credits}))
    18001800            return
    1801         IWorkflowInfo(self.context.getStudent()).fireTransition(
     1801        IWorkflowInfo(self.context.student).fireTransition(
    18021802            'register_courses')
    18031803        self.flash(_('Course list has been registered.'))
     
    18141814
    18151815    def update(self):
    1816         if self.context.getStudent().state != PAID:
     1816        if self.context.student.state != PAID:
    18171817            emit_lock_message(self)
    18181818            return
     
    18231823    def addCourseTicket(self, **data):
    18241824        # Safety belt
    1825         if self.context.getStudent().state != PAID:
     1825        if self.context.student.state != PAID:
    18261826            return
    18271827        ticket = createObject(u'waeup.CourseTicket')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r8576 r8736  
    146146            value = value.code
    147147        if name == 'student_id' and context is not None:
    148             student = context.getStudent()
     148            student = context.student
    149149            value = getattr(student, name, None)
    150150        return super(
     
    181181        """
    182182        if name == 'student_id' and context is not None:
    183             student = context.getStudent()
     183            student = context.student
    184184            value = getattr(student, name, None)
    185185        return super(
     
    214214        """
    215215        if context is not None:
    216             student = context.getStudent()
     216            student = context.student
    217217            if name == 'student_id' and student is not None:
    218218                value = getattr(student, name, None)
     
    251251        """
    252252        if context is not None:
    253             student = context.getStudent()
     253            student = context.student
    254254            if name in ['student_id'] and student is not None:
    255255                value = getattr(student, name, None)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r8735 r8736  
    132132
    133133    """
    134     def getStudent():
    135         """Return student object.
    136 
    137         """
     134    student = Attribute('Student object of context.')
    138135
    139136    def writeLogMessage(view, message):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r8735 r8736  
    4040        return
    4141
    42     def getStudent(self):
     42    @property
     43    def student(self):
    4344        return self.__parent__
    4445
     
    5859        return
    5960
    60     def getStudent(self):
     61    @property
     62    def student(self):
    6163        try:
    6264            return self.__parent__.__parent__
     
    6870
    6971    def _createActivationCodes(self):
    70         student = self.getStudent()
     72        student = self.student
    7173        if self.p_category == 'clearance':
    7274            # Create CLR access code
     
    132134    def display_fullname(self):
    133135        "Name of  payee."
    134         return self.context.getStudent().display_fullname
     136        return self.context.student.display_fullname
    135137
    136138    @property
    137139    def id(self):
    138140        "Id of payee"
    139         return self.context.getStudent().student_id
     141        return self.context.student.student_id
    140142
    141143    @property
    142144    def faculty(self):
    143145        "Faculty of payee"
    144         return self.context.getStudent().faccode
     146        return self.context.student.faccode
    145147
    146148    @property
    147149    def department(self):
    148150        "Department of payee"
    149         return self.context.getStudent().depcode
     151        return self.context.student.depcode
    150152
    151153# Student online payments must be importable. So we might need a factory.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r8735 r8736  
    9696        return history
    9797
    98     def getStudent(self):
     98    @property
     99    def student(self):
    99100        return self
    100101
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py

    r8735 r8736  
    4040        return
    4141
    42     def getStudent(self):
     42    @property
     43    def student(self):
    4344        return self.__parent__
    4445
     
    5152        if certificate == None:
    5253            return False
    53         if self.getStudent().state in (CLEARED, RETURNING):
     54        if self.student.state in (CLEARED, RETURNING):
    5455            return True
    55         if self.getStudent().state == PAID \
    56             and self.getStudent().is_postgrad:
     56        if self.student.state == PAID \
     57            and self.student.is_postgrad:
    5758            return True
    5859        return False
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r8735 r8736  
    4141        return
    4242
    43     def getStudent(self):
    44         return getattr(getattr(self, '__parent__', None), '__parent__', None)
     43    @property
     44    def student(self):
     45        try:
     46            return self.__parent__.__parent__
     47        except AttributeError:
     48            return None
    4549
    4650    def writeLogMessage(self, view, message):
     
    101105        return
    102106
    103     def getStudent(self):
     107    @property
     108    def student(self):
    104109        """Get the associated student object.
    105110        """
    106         # XXX: shouldn't that be an attribute?
    107111        try:
    108112            return self.__parent__.__parent__.__parent__
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r8735 r8736  
    7474
    7575    def render(self):
    76         url = self.view.url(self.context.getStudent(), self.link)
     76        url = self.view.url(self.context.student, self.link)
    7777        # Here we know that the cookie has been set
    7878        lang = self.request.cookies.get('kofa.language')
     
    8989    def render(self):
    9090        slip = getUtility(IExtFileStore).getFileByContext(
    91             self.context.getStudent(), attr=self.link)
     91            self.context.student, attr=self.link)
    9292        if slip:
    9393            url = self.view.url(self.context,self.link)
     
    266266    @property
    267267    def target_url(self):
    268         if self.context.getStudent().state != REGISTERED or \
     268        if self.context.student.state != REGISTERED or \
    269269            str(self.context.__parent__.current_level) != self.context.__name__:
    270270            return ''
     
    282282    @property
    283283    def target_url(self):
    284         if self.context.getStudent().state not in (VALIDATED, REGISTERED) or \
     284        if self.context.student.state not in (VALIDATED, REGISTERED) or \
    285285            str(self.context.__parent__.current_level) != self.context.__name__:
    286286            return ''
     
    456456    @property
    457457    def target_url(self):
    458         student = self.view.context.getStudent()
     458        student = self.view.context.student
    459459        condition1 = student.state != PAID
    460460        condition2 = str(student['studycourse'].current_level) in \
     
    474474    @property
    475475    def target_url(self):
    476         student = self.view.context.getStudent()
     476        student = self.view.context.student
    477477        condition1 = student.state != PAID
    478478        condition2 = student[
     
    545545            '/students/%s' % self.request.principal.id)
    546546        #app_slip = getUtility(IExtFileStore).getFileByContext(
    547         #    self.context.getStudent(), 'application_slip')
     547        #    self.context.student, 'application_slip')
    548548        targets = []
    549549        #if app_slip:
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r8735 r8736  
    693693    # (applyData does this only for the context)
    694694    if 'certificate' in changed_fields:
    695         notify(grok.ObjectModifiedEvent(view.context.getStudent()))
     695        notify(grok.ObjectModifiedEvent(view.context.student))
    696696    fields_string = ' + '.join(changed_fields)
    697697    view.flash(_('Form has been saved.'))
Note: See TracChangeset for help on using the changeset viewer.