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

Remove maintenance fee attributes. We don't need them in bed tickets.

Add BedTicketDisplayFormPage?.

getPaymentDetails and getAccommodationDetails: Return dictionary instead of tuple.

Callback now provides a HOS pin when applied to IStudentOnlinePayment instances.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py

    r6929 r6994  
    1111    ('School Fee','schoolfee'),
    1212    ('Clearance','clearance'),
     13    ('Bed Allocation','bed_allocation'),
    1314    ('Hostel Maintenance','hostel_maintenance'),
    1415    ('Transfer','transfer'),
  • main/waeup.sirp/trunk/src/waeup/sirp/students/accommodation.py

    r6992 r6994  
    2121from grok import index
    2222from zope.component.interfaces import IFactory
     23from waeup.sirp.interfaces import academic_sessions_vocab
    2324from waeup.sirp.students.interfaces import (
    2425    IStudentAccommodation, IStudentNavigation, IBedTicket)
     
    6465        return self.__parent__.__parent__
    6566
     67    def getSessionString(self):
     68        return academic_sessions_vocab.getTerm(
     69            self.booking_session).title
     70
    6671BedTicket = attrs_to_fields(BedTicket)
    6772
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6993 r6994  
    128128    title = u'Accommodation'
    129129
     130class BedTicketBreadcrumb(Breadcrumb):
     131    """A breadcrumb for bed tickets.
     132    """
     133    grok.context(IBedTicket)
     134    @property
     135
     136    def title(self):
     137        return 'Bed Ticket %s' % self.context.getSessionString()
     138
    130139class StudyLevelBreadcrumb(Breadcrumb):
    131140    """A breadcrumb for course lists.
     
    898907        #order_id = "%s%s" % (student_id[1:],timestamp)
    899908        payment.p_id = "p%s" % timestamp
    900         (payment.amount_auth,
    901             payment.p_item, payment.p_session,
    902             payment.surcharge_1,
    903             payment.surcharge_2,
    904             payment.surcharge_3,
    905             error)  = self.getPaymentDetails(
     909        pay_details  = self.getPaymentDetails(
    906910            data['p_category'],self.context.__parent__)
    907         if error:
    908             self.flash(error)
     911        if pay_details['error']:
     912            self.flash(pay_details['error'])
    909913            self.redirect(self.url(self.context))
    910914            return
     915        payment.amount_auth = pay_details['amount']
     916        payment.p_item = pay_details['p_item']
     917        payment.p_session = pay_details['p_session']
     918        payment.surcharge_1 = pay_details['surcharge_1']
     919        payment.surcharge_2 = pay_details['surcharge_2']
     920        payment.surcharge_3 = pay_details['surcharge_3']
    911921        self.context[payment.p_id] = payment
    912922        self.flash('Payment ticket created.')
     
    966976                return
    967977            self.context.ac = pin
     978        elif self.context.p_category == 'bed_allocation':
     979            # Create HOS access code
     980            pin, error = create_accesscode('HOS',0,student.student_id)
     981            if error:
     982                self.flash('Valid callback received. ' + error)
     983                return
     984            self.context.ac = pin
    968985        self.flash('Valid callback received.')
    969986        return
     
    10721089
    10731090    def update(self, SUBMIT=None):
    1074         (booking_session, booking_fee, maint_fee, allowed_states,
    1075             error)  = self.getAccommodationDetails(self.context.__parent__)
    1076         if not self.context.getStudent().state in allowed_states:
     1091        acc_details  = self.getAccommodationDetails(self.context.__parent__)
     1092        if not self.context.getStudent().state in acc_details['allowed_states']:
    10771093            self.flash("Wrong state.")
    10781094            self.redirect(self.url(self.context))
     
    11021118        bedticket = createObject(u'waeup.BedTicket')
    11031119        bedticket.booking_code = pin
     1120        bedticket.booking_session = acc_details['booking_session']
    11041121        bedticket.bed = u'Test Bed'
    1105         self.context['test'] = bedticket
     1122        self.context[str(acc_details['booking_session'])] = bedticket
    11061123        self.flash('Bed ticket created.')
    11071124        self.redirect(self.url(self.context))
    11081125        return
     1126
     1127class BedTicketDisplayFormPage(WAeUPDisplayFormPage):
     1128    """ Page to display bed tickets
     1129    """
     1130    grok.context(IBedTicket)
     1131    grok.name('index')
     1132    grok.require('waeup.viewStudent')
     1133    form_fields = grok.AutoFields(IBedTicket)
     1134    form_fields[
     1135        'booking_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1136    pnav = 4
     1137
     1138    @property
     1139    def label(self):
     1140        return 'Bed Ticket for Session %s' % self.context.getSessionString()
     1141
     1142    @property
     1143    def title(self):
     1144        return 'Bed Ticket %s' % self.context.getSessionString()
    11091145
    11101146class StudentHistoryPage(WAeUPPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6992 r6994  
    346346        )
    347347
    348     booking_fee =schema.Int(
    349         title = u'Booking Fee',
    350         default = 0,
    351         required = False,
    352         readonly = False,
    353         )
    354 
    355     maint_date = schema.Datetime(
    356         title = u'Maintenance Fee Payment Date',
    357         required = False,
    358         readonly = False,
    359         )
    360 
    361     maint_code = schema.TextLine(
    362         title = u'Maintenance Fee Payment Code',
    363         default = u'Certificate XYZ',
    364         required = False,
    365         readonly = False,
    366         )
    367 
    368     maint_fee = schema.Int(
    369         title = u'Maintenance Fee',
    370         default = 0,
    371         required = False,
    372         readonly = False,
    373         )
     348    def getSessionString():
     349        """Returns the the title of academic_sessions_vocab term
     350        """
    374351
    375352class IStudentPaymentsContainer(IPaymentsContainer):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6993 r6994  
    2424# This function is for demonstration and testing only.
    2525def getPaymentDetails(category, student):
    26     surcharge_1 = surcharge_2 = surcharge_3 = 0
    27     p_item = u''
    28     amount = 0
    29     error = u''
    30     p_session = student['studycourse'].current_session
    31     session = str(p_session)
     26    d = {}
     27    d['p_item'] = u''
     28    d['amount'] = 0
     29    d['error'] = u''
     30    d['p_session'] = student['studycourse'].current_session
     31    session = str(d['p_session'])
    3232    try:
    3333        academic_session = getSite()['configuration'][session]
    3434    except KeyError:
    35         error = u'Session configuration object is not available.'
    36         return (amount, p_item, p_session,
    37             surcharge_1, surcharge_2, surcharge_3, error)
     35        d['error'] = u'Session configuration object is not available.'
     36        return d
     37    d['surcharge_1'] = academic_session.surcharge_1
     38    d['surcharge_2'] = academic_session.surcharge_2
     39    d['surcharge_3'] = academic_session.surcharge_3
    3840    if category == 'schoolfee':
    39         amount = academic_session.fee_1
    40         surcharge_1 = academic_session.surcharge_1
    41         surcharge_2 = academic_session.surcharge_2
    42         surcharge_3 = academic_session.surcharge_3
    43         p_item = student['studycourse'].certificate.code
     41        d['amount'] = academic_session.fee_1
     42        d['p_item'] = student['studycourse'].certificate.code
    4443    elif category == 'clearance':
    45         p_item = student['studycourse'].certificate.code
    46         amount = academic_session.fee_2
    47     return (amount, p_item, p_session,
    48         surcharge_1, surcharge_2, surcharge_3, error)
     44        d['p_item'] = student['studycourse'].certificate.code
     45        d['amount'] = academic_session.fee_2
     46    elif category == 'bed_allocation':
     47        #d['p_item'] = student['studycourse'].certificate.code
     48        d['amount'] = academic_session.booking_fee
     49    return d
    4950
    5051# To be specified in customization packages.
    5152# This function is for demonstration and testing only.
    5253def getAccommodationDetails(student):
    53     bookin_fee = maint_fee = 0
    54     error = u''
     54    d = {}
     55    d['bookin_fee'] = d['maint_fee'] = 0
     56    d['error'] = u''
    5557    site_confoguration = getSite()['configuration']
    56     booking_session = site_confoguration.accommodation_session
    57     allowed_states = site_confoguration.accommodation_states
    58     session = str(booking_session)
    59     try:
    60         academic_session = getSite()['configuration'][session]
    61     except KeyError:
    62         error = u'Session configuration object is not available.'
    63         return (booking_session, booking_fee, maint_fee, allowed_states,
    64             error)
    65     booking_fee = academic_session.booking_fee
    66     maint_fee = academic_session.maint_fee
    67     return booking_session, booking_fee, maint_fee, allowed_states, error
     58    d['booking_session'] = site_confoguration.accommodation_session
     59    d['allowed_states'] = site_confoguration.accommodation_states
     60    session = str(d['booking_session'])
     61    return d
Note: See TracChangeset for help on using the changeset viewer.