import grok from time import time from zope.component import createObject from waeup.sirp.students.browser import OnlinePaymentAddFormPage from waeup.custom.students.utils import getPaymentDetails class OnlinePaymentAddFormPage(OnlinePaymentAddFormPage): """ Page to add an online payment ticket """ @grok.action('Create ticket') def createTicket(self, **data): payment = createObject(u'waeup.StudentOnlinePayment') self.applyData(payment, **data) timestamp = "%d" % int(time()*1000) #order_id = "%s%s" % (student_id[1:],timestamp) payment.p_id = "p%s" % timestamp (payment.amount_auth, payment.p_item, payment.p_session, payment.surcharge_1, payment.surcharge_2, payment.surcharge_3) = getPaymentDetails( data['p_category'],self.context.__parent__) if payment.amount_auth == 0: self.flash('Payment amount could not be determined.') self.redirect(self.url(self.context, u'@@manage')) return self.context[payment.p_id] = payment self.flash('Payment ticket created.') self.redirect(self.url(self.context, u'@@manage')) return