Changeset 9862


Ignore:
Timestamp:
11 Jan 2013, 09:03:19 (12 years ago)
Author:
Henrik Bettermann
Message:

Derive PreviousPaymentAddFormPage? from KofaAddFormPage? and simplify createTicket. A similar view will be used for balance payments.

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

Legend:

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

    r9857 r9862  
    14741474        self.redirect(self.url(self.context))
    14751475
    1476 class PreviousPaymentAddFormPage(OnlinePaymentAddFormPage):
     1476class PreviousPaymentAddFormPage(KofaAddFormPage):
    14771477    """ Page to add an online payment ticket for previous sessions
    14781478    """
     
    14861486    pnav = 4
    14871487
     1488    @property
     1489    def selectable_categories(self):
     1490        categories = getUtility(
     1491            IKofaUtils).SELECTABLE_PREVIOUS_PAYMENT_CATEGORIES
     1492        return sorted(categories.items())
     1493
    14881494    def update(self):
    14891495        if self.context.student.before_payment:
     
    14921498        super(PreviousPaymentAddFormPage, self).update()
    14931499        return
     1500
     1501    @action(_('Create ticket'), style='primary')
     1502    def createTicket(self, **data):
     1503        p_category = data['p_category']
     1504        previous_session = data.get('p_session', None)
     1505        previous_level = data.get('p_level', None)
     1506        student = self.context.__parent__
     1507        students_utils = getUtility(IStudentsUtils)
     1508        error, payment = students_utils.setPaymentDetails(
     1509            p_category, student, previous_session, previous_level)
     1510        if error is not None:
     1511            self.flash(error)
     1512            return
     1513        self.context[payment.p_id] = payment
     1514        self.flash(_('Payment ticket created.'))
     1515        self.redirect(self.url(self.context))
     1516        return
     1517
     1518    @action(_('Cancel'), validator=NullValidator)
     1519    def cancel(self, **data):
     1520        self.redirect(self.url(self.context))
    14941521
    14951522class OnlinePaymentDisplayFormPage(KofaDisplayFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r9730 r9862  
    162162
    163163    SELECTABLE_PAYMENT_CATEGORIES = PAYMENT_CATEGORIES
     164
     165    SELECTABLE_PREVIOUS_PAYMENT_CATEGORIES = SELECTABLE_PAYMENT_CATEGORIES
    164166
    165167    MODE_GROUPS = {
Note: See TracChangeset for help on using the changeset viewer.