Ignore:
Timestamp:
20 Nov 2011, 07:35:35 (13 years ago)
Author:
Henrik Bettermann
Message:

Turn all functions subject to customization into methods of a global utility component called StudentsUtils?. This is really an incredible improvement and eases customization a lot.

File:
1 edited

Legend:

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

    r7147 r7150  
    4545    IStudentAccommodation, IStudentClearanceEdit, IStudentStudyLevel,
    4646    ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer,
    47     IStudentOnlinePayment, IBedTicket
     47    IStudentOnlinePayment, IBedTicket, IStudentsUtils
    4848    )
    4949from waeup.sirp.students.catalog import search
     
    5252from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
    5353from waeup.sirp.students.vocabularies import StudyLevelSource
    54 from waeup.sirp.students.utils import (
    55     get_payment_details, get_accommodation_details, select_bed,
    56     render_pdf)
    5754from waeup.sirp.browser.resources import toggleall
    5855from waeup.sirp.authentication import get_principal_role_manager
     
    667664        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
    668665            self.request)
    669         return render_pdf(self,'Course Registration', 'course_registration.pdf',
     666        students_utils = getUtility(IStudentsUtils)
     667        return students_utils.render_pdf(
     668            self,'Course Registration', 'course_registration.pdf',
    670669            self.context.getStudent, studentview)
    671670
     
    939938    pnav = 4
    940939   
    941     # To be sepezified in customization packages
    942     def get_payment_details(self, category, student):
    943         return get_payment_details(category, student)
    944 
    945940    @grok.action('Create ticket')
    946941    def createTicket(self, **data):
     
    954949                self.redirect(self.url(self.context))
    955950                return
    956         pay_details  = self.get_payment_details(
     951        students_utils = getUtility(IStudentsUtils)
     952        pay_details  = students_utils.get_payment_details(
    957953            p_category,student)
    958954        if pay_details['error']:
     
    11081104        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
    11091105            self.request)
    1110         return render_pdf(self,'Payment', 'payment_receipt.pdf',
     1106        students_utils = getUtility(IStudentsUtils)
     1107        return students_utils.render_pdf(self,'Payment', 'payment_receipt.pdf',
    11111108            self.context.getStudent, studentview)
    11121109
     
    12171214    notice = ''
    12181215
    1219     # To be sepezified in customization packages
    1220     def get_accommodation_details(self, student):
    1221         return get_accommodation_details(student)
    1222 
    1223     # To be sepezified in customization packages
    1224     def select_bed(self, available_beds):
    1225         return select_bed(available_beds)
    1226 
    12271216    def update(self, SUBMIT=None):
    12281217        student = self.context.getStudent()
    1229         acc_details  = self.get_accommodation_details(student)
     1218        students_utils = getUtility(IStudentsUtils)
     1219        acc_details  = students_utils.get_accommodation_details(student)
    12301220        if not student.state in acc_details['allowed_states']:
    12311221            self.flash("You are in the wrong registration state.")
     
    12641254                entry for entry in entries if entry.owner == NOT_OCCUPIED]
    12651255            if available_beds:
    1266                 bed = self.select_bed(available_beds)
     1256                students_utils = getUtility(IStudentsUtils)
     1257                bed = students_utils.select_bed(available_beds)
    12671258                bed.bookBed(student.student_id)
    12681259            else:
     
    13451336        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
    13461337            self.request)
    1347         return render_pdf(self,'Bed Allocation', 'bed_allocation.pdf',
     1338        students_utils = getUtility(IStudentsUtils)
     1339        return students_utils.render_pdf(
     1340            self,'Bed Allocation', 'bed_allocation.pdf',
    13481341            self.context.getStudent, studentview)
    13491342
     
    13641357    grok.require('waeup.manageHostels')
    13651358
    1366     # To be sepezified in customization packages
    1367     def get_accommodation_details(self, student):
    1368         return get_accommodation_details(student)
    1369 
    1370     # To be sepezified in customization packages
    1371     def select_bed(self, available_beds):
    1372         return select_bed(available_beds)
    1373 
    13741359    # Relocate student if student parameters have changed or the bed_type
    13751360    # of the bed has changed
    13761361    def update(self):
    13771362        student = self.context.getStudent()
    1378         acc_details  = self.get_accommodation_details(student)
     1363        students_utils = getUtility(IStudentsUtils)
     1364        acc_details  = students_utils.get_accommodation_details(student)
    13791365        if self.context.bed != None and \
    13801366              'reserved' in self.context.bed.bed_type:
     
    14031389                entry for entry in entries if entry.owner == NOT_OCCUPIED]
    14041390            if available_beds:
    1405                 new_bed = self.select_bed(available_beds)
     1391                students_utils = getUtility(IStudentsUtils)
     1392                new_bed = students_utils.select_bed(available_beds)
    14061393                new_bed.bookBed(student.student_id)
    14071394            else:
Note: See TracChangeset for help on using the changeset viewer.