Changeset 6869


Ignore:
Timestamp:
10 Oct 2011, 16:50:11 (13 years ago)
Author:
Henrik Bettermann
Message:

Add user interfaces to add, remove and manage student online payments.

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  
    11##
    22## interfaces.py
     3from zope.interface import Attribute, invariant
    34from zope import schema
    45from waeup.sirp.interfaces import IWAeUPObject
     
    1516
    1617    """
     18    p_id = Attribute('Payment identifier.')
    1719
    1820    p_state = schema.Choice(
     
    3234    p_item = schema.TextLine(
    3335        title = u'Payment Item',
    34         default = u'Certificate XYZ',
     36        default = None,
    3537        required = False,
    3638        )
    3739
    38     date_of_creation = schema.Date(
     40    creation_date = schema.Datetime(
    3941        title = u'Ticket Creation Date',
     42        readonly = True,
    4043        )
    4144
    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,
    4449        )
    4550
    4651    amount_auth = schema.Int(
    47         title = u'Amount authorized',
     52        title = u'Amount Authorized',
    4853        default = 0,
    4954        required = True,
     55        readonly = True,
    5056        )
    5157
     
    5965        default = u'Certificate XYZ',
    6066        required = False,
     67        readonly = True,
    6168        )
    6269
     
    7077        default = 0,
    7178        required = False,
     79        readonly = True,
    7280        )
    7381
    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    #    )
    7887
    7988    r_amount_approved = schema.Int(
     
    8190        default = 0,
    8291        required = False,
     92        readonly = True,
    8393        )
    8494
     
    8696        title = u'Response Code',
    8797        default = None,
     98        required = False,
     99        readonly = True,
    88100        )
    89101
     
    91103        title = u'Response Card Number',
    92104        default = None,
     105        required = False,
     106        readonly = True,
    93107        )
  • main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py

    r6866 r6869  
    1818"""
    1919import grok
     20from datetime import datetime
    2021from grok import index
    2122from zope.component.interfaces import IFactory
     
    2425    IPayment, ISCPayment, IOnlinePayment)
    2526from waeup.sirp.utils.helpers import attrs_to_fields
     27from waeup.sirp.payments.vocabularies import payment_states, payment_categories
    2628
    2729class Payment(grok.Container):
     
    3436    def __init__(self):
    3537        super(Payment, self).__init__()
     38        self.creation_date = datetime.now()
     39        self.p_id = None
    3640        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
    3749
    3850class SCPayment(Payment):
     
    4456    def __init__(self):
    4557        super(SCPayment, self).__init__()
     58        p_id = None
    4659        return
    4760
     
    5669    def __init__(self):
    5770        super(OnlinePayment, self).__init__()
     71        p_id = None
    5872        return
    5973
  • main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py

    r6865 r6869  
    44
    55payment_states = SimpleWAeUPVocabulary(
    6     ('not yet paid','unpaid'),
    7     ('paid','paid'),
     6    ('Not yet paid','unpaid'),
     7    ('Paid','paid'),
    88    )
    99
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6859 r6869  
    1717"""
    1818import grok
    19 
     19from time import time
     20from datetime import date, datetime
    2021from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2122from zope.component import createObject
     
    3031from waeup.sirp.interfaces import IWAeUPObject, IUserAccount
    3132from waeup.sirp.widgets.datewidget import (
    32     FriendlyDateWidget, FriendlyDateDisplayWidget)
     33    FriendlyDateWidget, FriendlyDateDisplayWidget,
     34    FriendlyDatetimeDisplayWidget)
    3335from waeup.sirp.students.interfaces import (
    3436    IStudentsContainer, IStudent, IStudentClearance, IStudentPasswordSetting,
     
    4244from waeup.sirp.students.vocabularies import StudyLevelSource
    4345from waeup.sirp.browser.resources import toggleall
     46from waeup.sirp.payments.interfaces import IOnlinePayment
    4447
    4548# Save function used for save methods in manager pages
     
    757760    grok.require('waeup.viewStudent')
    758761    form_fields = grok.AutoFields(IStudentPaymentsContainer)
    759     #grok.template('paymentspage')
     762    grok.template('paymentspage')
    760763    title = 'Payments'
    761764    pnav = 4
    762765
     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
    763772    @property
    764773    def label(self):
    765774        return '%s: Payments' % self.context.__parent__.fullname
     775
     776    def update(self):
     777        super(PaymentsDisplayFormPage, self).update()
     778        datatable.need()
     779        return
     780
     781class 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
     835class 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
     843class 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
     868class 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)
    766887
    767888class AccommodationDisplayFormPage(WAeUPDisplayFormPage):
Note: See TracChangeset for help on using the changeset viewer.