Changeset 6869
- Timestamp:
- 10 Oct 2011, 16:50:11 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/payments/interfaces.py
r6865 r6869 1 1 ## 2 2 ## interfaces.py 3 from zope.interface import Attribute, invariant 3 4 from zope import schema 4 5 from waeup.sirp.interfaces import IWAeUPObject … … 15 16 16 17 """ 18 p_id = Attribute('Payment identifier.') 17 19 18 20 p_state = schema.Choice( … … 32 34 p_item = schema.TextLine( 33 35 title = u'Payment Item', 34 default = u'Certificate XYZ',36 default = None, 35 37 required = False, 36 38 ) 37 39 38 date_of_creation = schema.Date(40 creation_date = schema.Datetime( 39 41 title = u'Ticket Creation Date', 42 readonly = True, 40 43 ) 41 44 42 date_of_payment = schema.Date( 43 title = u'Date of Payment', 45 payment_date = schema.Date( 46 title = u'Payment Date', 47 required = False, 48 readonly = True, 44 49 ) 45 50 46 51 amount_auth = schema.Int( 47 title = u'Amount authorized',52 title = u'Amount Authorized', 48 53 default = 0, 49 54 required = True, 55 readonly = True, 50 56 ) 51 57 … … 59 65 default = u'Certificate XYZ', 60 66 required = False, 67 readonly = True, 61 68 ) 62 69 … … 70 77 default = 0, 71 78 required = False, 79 readonly = True, 72 80 ) 73 81 74 order_id = schema.TextLine( 75 title = u'Order Id', 76 default = None, 77 ) 82 #order_id = schema.TextLine( 83 # title = u'Order Id', 84 # default = None, 85 # required = True, 86 # ) 78 87 79 88 r_amount_approved = schema.Int( … … 81 90 default = 0, 82 91 required = False, 92 readonly = True, 83 93 ) 84 94 … … 86 96 title = u'Response Code', 87 97 default = None, 98 required = False, 99 readonly = True, 88 100 ) 89 101 … … 91 103 title = u'Response Card Number', 92 104 default = None, 105 required = False, 106 readonly = True, 93 107 ) -
main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py
r6866 r6869 18 18 """ 19 19 import grok 20 from datetime import datetime 20 21 from grok import index 21 22 from zope.component.interfaces import IFactory … … 24 25 IPayment, ISCPayment, IOnlinePayment) 25 26 from waeup.sirp.utils.helpers import attrs_to_fields 27 from waeup.sirp.payments.vocabularies import payment_states, payment_categories 26 28 27 29 class Payment(grok.Container): … … 34 36 def __init__(self): 35 37 super(Payment, self).__init__() 38 self.creation_date = datetime.now() 39 self.p_id = None 36 40 return 41 42 @property 43 def state(self): 44 return payment_states.getTermByToken(self.p_state).title 45 46 @property 47 def category(self): 48 return payment_categories.getTermByToken(self.p_category).title 37 49 38 50 class SCPayment(Payment): … … 44 56 def __init__(self): 45 57 super(SCPayment, self).__init__() 58 p_id = None 46 59 return 47 60 … … 56 69 def __init__(self): 57 70 super(OnlinePayment, self).__init__() 71 p_id = None 58 72 return 59 73 -
main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py
r6865 r6869 4 4 5 5 payment_states = SimpleWAeUPVocabulary( 6 (' not yet paid','unpaid'),7 (' paid','paid'),6 ('Not yet paid','unpaid'), 7 ('Paid','paid'), 8 8 ) 9 9 -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6859 r6869 17 17 """ 18 18 import grok 19 19 from time import time 20 from datetime import date, datetime 20 21 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 21 22 from zope.component import createObject … … 30 31 from waeup.sirp.interfaces import IWAeUPObject, IUserAccount 31 32 from waeup.sirp.widgets.datewidget import ( 32 FriendlyDateWidget, FriendlyDateDisplayWidget) 33 FriendlyDateWidget, FriendlyDateDisplayWidget, 34 FriendlyDatetimeDisplayWidget) 33 35 from waeup.sirp.students.interfaces import ( 34 36 IStudentsContainer, IStudent, IStudentClearance, IStudentPasswordSetting, … … 42 44 from waeup.sirp.students.vocabularies import StudyLevelSource 43 45 from waeup.sirp.browser.resources import toggleall 46 from waeup.sirp.payments.interfaces import IOnlinePayment 44 47 45 48 # Save function used for save methods in manager pages … … 757 760 grok.require('waeup.viewStudent') 758 761 form_fields = grok.AutoFields(IStudentPaymentsContainer) 759 #grok.template('paymentspage')762 grok.template('paymentspage') 760 763 title = 'Payments' 761 764 pnav = 4 762 765 766 def formatDatetime(self,datetimeobj): 767 if isinstance(datetimeobj, datetime): 768 return datetimeobj.strftime("%Y-%m-%d %H:%M:%S") 769 else: 770 return None 771 763 772 @property 764 773 def label(self): 765 774 return '%s: Payments' % self.context.__parent__.fullname 775 776 def update(self): 777 super(PaymentsDisplayFormPage, self).update() 778 datatable.need() 779 return 780 781 class PaymentsManageFormPage(WAeUPEditFormPage): 782 """ Page to manage the student payments 783 """ 784 grok.context(IStudentPaymentsContainer) 785 grok.name('manage') 786 grok.require('waeup.manageStudents') 787 form_fields = grok.AutoFields(IStudentPaymentsContainer) 788 grok.template('paymentsmanagepage') 789 title = 'Payments' 790 pnav = 4 791 792 def formatDatetime(self,datetimeobj): 793 if isinstance(datetimeobj, datetime): 794 return datetimeobj.strftime("%Y-%m-%d %H:%M:%S") 795 else: 796 return None 797 798 @property 799 def label(self): 800 return '%s: Payments' % self.context.__parent__.fullname 801 802 def update(self): 803 super(PaymentsManageFormPage, self).update() 804 datatable.need() 805 return 806 807 @grok.action('Remove selected tickets') 808 def delPaymentTicket(self, **data): 809 form = self.request.form 810 if form.has_key('val_id'): 811 child_id = form['val_id'] 812 else: 813 self.flash('No payment selected.') 814 self.redirect(self.url(self.context, '@@manage')) 815 return 816 if not isinstance(child_id, list): 817 child_id = [child_id] 818 deleted = [] 819 for id in child_id: 820 try: 821 del self.context[id] 822 deleted.append(id) 823 except: 824 self.flash('Could not delete %s: %s: %s' % ( 825 id, sys.exc_info()[0], sys.exc_info()[1])) 826 if len(deleted): 827 self.flash('Successfully removed: %s' % ', '.join(deleted)) 828 self.redirect(self.url(self.context, u'@@manage')) 829 return 830 831 @grok.action('Add online payment ticket') 832 def addPaymentTicket(self, **data): 833 self.redirect(self.url(self.context, '@@addop')) 834 835 class OnlinePaymentManageActionButton(ManageActionButton): 836 grok.order(1) 837 grok.context(IStudentPaymentsContainer) 838 grok.view(PaymentsDisplayFormPage) 839 grok.require('waeup.manageStudents') 840 text = 'Manage payments' 841 target = 'manage' 842 843 class OnlinePaymentAddFormPage(WAeUPAddFormPage): 844 """ Page to add an online payment ticket 845 """ 846 grok.context(IStudentPaymentsContainer) 847 grok.name('addop') 848 grok.require('waeup.handleStudent') 849 form_fields = grok.AutoFields(IOnlinePayment).select( 850 'p_category') 851 #grok.template('addpaymentpage') 852 label = 'Add online payment' 853 title = 'Payments' 854 pnav = 4 855 856 @grok.action('Create ticket') 857 def createTicket(self, **data): 858 payment = createObject(u'waeup.OnlinePayment') 859 self.applyData(payment, **data) 860 timestamp = "%d" % int(time()*1000) 861 #order_id = "%s%s" % (student_id[1:],timestamp) 862 payment.p_id = "p%s" % timestamp 863 self.context[payment.p_id] = payment 864 self.flash('Payment ticket created.') 865 self.redirect(self.url(self.context, u'@@manage')) 866 return 867 868 class OnlinePaymentDisplayFormPage(WAeUPDisplayFormPage): 869 """ Page to view an online payment ticket 870 """ 871 grok.context(IOnlinePayment) 872 grok.name('index') 873 grok.require('waeup.viewStudent') 874 form_fields = grok.AutoFields(IOnlinePayment) 875 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 876 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 877 pnav = 4 878 879 @property 880 def title(self): 881 return 'Online Payment Ticket %s' % self.context.p_id 882 883 @property 884 def label(self): 885 return '%s: Online Payment Ticket %s' % ( 886 self.context.__parent__.__parent__.fullname,self.context.p_id) 766 887 767 888 class AccommodationDisplayFormPage(WAeUPDisplayFormPage):
Note: See TracChangeset for help on using the changeset viewer.