Ignore:
Timestamp:
25 Nov 2022, 11:54:59 (2 years ago)
Author:
Henrik Bettermann
Message:

Allow students to book accommodation also if they are in previous sessions (not activated in base package).

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py

    r15250 r17176  
    2828    bed_letters, blocks, SpecialHandlingSource,
    2929    NOT_OCCUPIED)
     30from waeup.kofa.students.interfaces import (IStudentsUtils)
    3031
    3132# Define a validation method for sort ids
     
    285286            return
    286287        catalog = getUtility(ICatalog, name='students_catalog')
     288        accommodation_span = getUtility(IStudentsUtils).ACCOMMODATION_SPAN
    287289        accommodation_session = getSite()['hostels'].accommodation_session
    288290        students = catalog.searchResults(current_session=(
    289             accommodation_session,accommodation_session))
     291            accommodation_session-accommodation_span,accommodation_session))
    290292        student_ids = [student.student_id for student in students]
    291293        if not bed.owner in student_ids:
    292294            raise Invalid(_(
    293295                "Either student does not exist or student "
    294                 "is not in accommodation session."))
     296                "is not eligible to book accommodation."))
    295297        catalog = getUtility(ICatalog, name='beds_catalog')
    296298        beds = catalog.searchResults(owner=(bed.owner,bed.owner))
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r15250 r17176  
    452452        self.assertMatches(
    453453            "...Either student does not exist or student "
    454             "is not in accommodation session...",
     454            "is not eligible to book accommodation...",
    455455            self.browser.contents)
    456456        self.browser.getControl(name="form.owner").value = self.student_id
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r16939 r17176  
    22642264            p_combi = [p_combi,]
    22652265        student = self.context.__parent__
     2266        students_utils = getUtility(IStudentsUtils)
    22662267        # The hostel_application payment category is temporarily used
    22672268        # by Uniben.
    2268         if p_category in ('bed_allocation', 'hostel_application') and student[
    2269             'studycourse'].current_session != grok.getSite()[
    2270             'hostels'].accommodation_session:
     2269        if p_category in (
     2270                'bed_allocation', 'hostel_application') and grok.getSite()[
     2271                    'hostels'].accommodation_session - student[
     2272                        'studycourse'].current_session > students_utils.ACCOMMODATION_SPAN:
    22712273                self.flash(
    2272                     _('Your current session does not match ' + \
    2273                     'accommodation session.'), type="danger")
     2274                    _('Your current session does not allow ' + \
     2275                    'to book accommodation.'), type="danger")
    22742276                return
    22752277        if 'maintenance' in p_category:
     
    22792281                           type="warning")
    22802282                return
    2281         students_utils = getUtility(IStudentsUtils)
    22822283        error, payment = students_utils.setPaymentDetails(
    22832284            p_category, student, None, None, p_combi)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r16834 r17176  
    14161416        self.app['hostels'].accommodation_session = 2011
    14171417        self.browser.getControl("Create ticket").click()
    1418         self.assertMatches('...Your current session does not match...',
     1418        self.assertMatches('...Your current session does not allow...',
    14191419                           self.browser.contents)
    14201420        self.app['hostels'].accommodation_session = 2004
     
    14391439        self.student['studycourse'].current_session = 2003
    14401440        self.browser.getControl("Book accommodation").click()
    1441         self.assertMatches('...Your current session does not match...',
    1442                            self.browser.contents)
     1441        self.assertMatches(
     1442            '...Your current session does not allow to book accommodation...',
     1443            self.browser.contents)
    14431444        self.student['studycourse'].current_session = 2004
    14441445        # All requirements are met and ticket can be created
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r16966 r17176  
    654654        return d
    655655
     656    ACCOMMODATION_SPAN = 0
     657
    656658    def checkAccommodationRequirements(self, student, acc_details):
    657659        if acc_details.get('expired', False):
     
    672674        if not student.state in acc_details['allowed_states']:
    673675            return _("You are in the wrong registration state.")
    674         if student['studycourse'].current_session != acc_details[
    675             'booking_session']:
    676             return _('Your current session does not '
    677                      'match accommodation session.')
     676        if  acc_details['booking_session'] - student[
     677            'studycourse'].current_session > self.ACCOMMODATION_SPAN:
     678            return _('Your current session does not allow ' + \
     679                    'to book accommodation.')
    678680        bsession = str(acc_details['booking_session'])
    679681        if bsession in student['accommodation'].keys() \
Note: See TracChangeset for help on using the changeset viewer.