Changeset 18181 for main


Ignore:
Timestamp:
22 Sep 2025, 20:27:42 (14 months ago)
Author:
Henrik Bettermann
Message:

Only fresh students can book accomodation. But officers can book also for returning students.

Location:
main/kofacustom.unidel/trunk/src/kofacustom/unidel/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser.py

    r17924 r18181  
    8484    with_ac = False
    8585
     86    def update(self, SUBMIT=None):
     87        if getattr(self.request.principal, 'user_type', None) == 'student':
     88            entry_session = self.context.student['studycourse'].entry_session
     89            if entry_session != grok.getSite()['hostels'].accommodation_session:
     90                error_message = 'Only newly admitted students can book accommodation.'
     91                self.flash(error_message, type="warning")
     92                self.redirect(self.url(self.context))
     93                return
     94        return super(CustomBedTicketAddPage, self).update(SUBMIT)
     95
    8696class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
    8797    """ Page to view bed tickets.
    … …  
    94104    """
    95105    with_hostel_selection = True
     106
     107    @property
     108    def booking_allowed(self):
     109        if getattr(self.request.principal, 'user_type', None) == 'student':
     110            entry_session = self.context.student['studycourse'].entry_session
     111            if entry_session != grok.getSite()['hostels'].accommodation_session:
     112                return False
     113        students_utils = getUtility(IStudentsUtils)
     114        acc_details  = students_utils.getAccommodationDetails(self.context.student)
     115        error_message = students_utils.checkAccommodationRequirements(
     116            self.context.student, acc_details)
     117        if error_message:
     118            return False
     119        return True
     120       
     121    @property
     122    def actionsgroup2(self):
     123        if getattr(self.request.principal, 'user_type', None) == 'student':
     124            ## Book button can be disabled in custom packages by
     125            ## uncommenting the following lines.
     126            if not self.booking_allowed:
     127                return []
     128            return [_('Book accommodation')]
     129        return [_('Book accommodation'), _('Remove selected')]
    96130
    97131class CustomPaymentsManageFormPage(PaymentsManageFormPage):
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/utils.py

    r18179 r18181  
    263263        return None, payment
    264264
    265     def checkAccommodationRequirements(self, student, acc_details):
     265    def disabled_checkAccommodationRequirements(self, student, acc_details):
    266266        msg = super(CustomStudentsUtils, self).checkAccommodationRequirements(
    267267            student, acc_details)
Note: See TracChangeset for help on using the changeset viewer.