source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser.py @ 8734

Last change on this file since 8734 was 8711, checked in by Henrik Bettermann, 13 years ago

Do not show transaction code (temporarily disabled).

  • Property svn:keywords set to Id
File size: 7.2 KB
RevLine 
[8012]1## $Id: browser.py 8711 2012-06-13 13:58:05Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""UI components for basic applicants and related components.
19"""
20import grok
[8259]21from zope.component import getUtility
22from zope.i18n import translate
[8247]23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[8259]24from waeup.kofa.students.interfaces import IStudentsUtils
[8090]25from waeup.kofa.applicants.interfaces import (
26    IApplicantRegisterUpdate, IApplicant, IApplicantEdit)
[8012]27from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
[8421]28    ExportPDFPage,
[8090]29    ApplicantManageFormPage, ApplicantEditFormPage,
[8247]30    ApplicantRegistrationPage, ApplicantAddFormPage,
[8263]31    OnlinePaymentDisplayFormPage, ApplicationFeePaymentAddPage,
[8259]32    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
33    ApplicantBaseDisplayFormPage)
34from waeup.kofa.applicants.viewlets import (
[8421]35    PaymentReceiptActionButton)
[8017]36from waeup.kofa.applicants.pdf import PDFApplicationSlip
[8444]37from waeup.aaue.applicants.interfaces import (
[8247]38    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit,
[8532]39    ICustomApplicantOnlinePayment, IPUTMEApplicantEdit,
[8521]40    UG_OMIT_DISPLAY_FIELDS, PG_OMIT_DISPLAY_FIELDS,
[8567]41    UG_OMIT_PDF_FIELDS, PG_OMIT_PDF_FIELDS,
[8521]42    UG_OMIT_MANAGE_FIELDS, PG_OMIT_MANAGE_FIELDS,
[8532]43    UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS, PUTME_OMIT_EDIT_FIELDS)
[8444]44from waeup.aaue.interfaces import MessageFactory as _
[8012]45
[8247]46#class RequestCallbackActionButton(RequestCallbackActionButton):
[8259]47#    """ Display the base package callback button in custom pages.
[8247]48#    """
[8259]49#    grok.context(ICustomApplicantOnlinePayment)
[8012]50
[8247]51#class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
[8259]52#    """ Activate callback simulation view
[8247]53#    """
[8259]54#    grok.context(ICustomApplicantOnlinePayment)
[8247]55
56class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
57    """A breadcrumb for payments.
[8012]58    """
[8247]59    grok.context(ICustomApplicantOnlinePayment)
[8012]60
[8259]61class PaymentReceiptActionButton(PaymentReceiptActionButton):
62    grok.order(4)
63    grok.context(ICustomApplicantOnlinePayment)
64
[8196]65class CustomPDFApplicationSlip(PDFApplicationSlip):
[8012]66
[8567]67    note = _(u'<br /><br /><br />'
68              'Comfirm your exam venue 72 hours to the exam.')
69
[8017]70    @property
71    def form_fields(self):
72        target = getattr(self.context.__parent__, 'prefix', None)
73        if target is not None and target.startswith('pg'):
[8521]74            form_fields = grok.AutoFields(IPGApplicant)
[8567]75            for field in PG_OMIT_PDF_FIELDS:
[8521]76                form_fields = form_fields.omit(field)
[8017]77        else:
[8521]78            form_fields = grok.AutoFields(IUGApplicant)
[8567]79            for field in UG_OMIT_PDF_FIELDS:
[8521]80                form_fields = form_fields.omit(field)
[8017]81        return form_fields
[8012]82
[8196]83class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
[8017]84    """A display view for applicant data.
85    """
[8012]86
87    @property
88    def form_fields(self):
89        target = getattr(self.context.__parent__, 'prefix', None)
90        if target is not None and target.startswith('pg'):
[8521]91            form_fields = grok.AutoFields(IPGApplicant)
92            for field in PG_OMIT_DISPLAY_FIELDS:
93                form_fields = form_fields.omit(field)
[8012]94        else:
[8521]95            form_fields = grok.AutoFields(IUGApplicant)
96            for field in UG_OMIT_DISPLAY_FIELDS:
97                form_fields = form_fields.omit(field)
[8012]98        return form_fields
99
[8196]100class CustomApplicantManageFormPage(ApplicantManageFormPage):
[8012]101    """A full edit view for applicant data.
102    """
[8017]103   
104    @property
105    def form_fields(self):
106        target = getattr(self.context.__parent__, 'prefix', None)
107        if target is not None and target.startswith('pg'):
108            form_fields = grok.AutoFields(IPGApplicant)
[8521]109            for field in PG_OMIT_MANAGE_FIELDS:
110                form_fields = form_fields.omit(field)
[8017]111        else:
112            form_fields = grok.AutoFields(IUGApplicant)
[8521]113            for field in UG_OMIT_MANAGE_FIELDS:
114                form_fields = form_fields.omit(field)
[8017]115        form_fields['student_id'].for_display = True
116        form_fields['applicant_id'].for_display = True
117        return form_fields
[8012]118
[8196]119class CustomApplicantEditFormPage(ApplicantEditFormPage):
[8012]120    """An applicant-centered edit view for applicant data.
121    """
[8017]122
123    @property
124    def form_fields(self):
125        target = getattr(self.context.__parent__, 'prefix', None)
126        if target is not None and target.startswith('pg'):
[8521]127            form_fields = grok.AutoFields(IPGApplicantEdit)
128            for field in PG_OMIT_EDIT_FIELDS:
129                form_fields = form_fields.omit(field)
[8532]130        elif target is not None and target.startswith('putme'):
131            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
132            for field in PUTME_OMIT_EDIT_FIELDS:
133                form_fields = form_fields.omit(field)
[8017]134        else:
[8521]135            form_fields = grok.AutoFields(IUGApplicantEdit)
136            for field in UG_OMIT_EDIT_FIELDS:
137                form_fields = form_fields.omit(field)
[8017]138        form_fields['applicant_id'].for_display = True
[8051]139        form_fields['reg_number'].for_display = True
[8017]140        return form_fields
[8247]141
142class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
143    """ Page to view an online payment ticket
144    """
145    grok.context(ICustomApplicantOnlinePayment)
[8263]146    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
[8247]147    form_fields[
148        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
149    form_fields[
150        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[8711]151    #grok.template('payment_view')
[8247]152
[8711]153    #@property
154    #def transaction_code(self):
155    #    tcode = self.context.p_id
156    #    return tcode[len(tcode)-8:len(tcode)]
[8247]157
[8263]158class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
[8247]159    """ Page to add an online payment ticket
160    """
161    factory = u'waeup.CustomApplicantOnlinePayment'
162
[8259]163class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
164    """Deliver a PDF slip of the context.
165    """
166    grok.context(ICustomApplicantOnlinePayment)
[8292]167    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
[8259]168    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
169    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
170
[8711]171#    @property
172#    def note(self):
173#        if self.context.p_state == 'paid':
174#            return None
175#        tcode = self.context.p_id
176#        tcode = tcode[len(tcode)-8:len(tcode)]
177#        amount = self.context.amount_auth
178#        note = translate(_(
179#            u"""<br /><br /><br />
180#The tranzaction code is <strong>${a}</strong>.""",
181#            mapping = {'a':tcode}))
182#        return note
Note: See TracBrowser for help on using the repository browser.