source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/browser.py @ 8528

Last change on this file since 8528 was 8528, checked in by Henrik Bettermann, 12 years ago

See r8526.

The comment in r8627 refers to this revision.

  • Property svn:keywords set to Id
File size: 6.8 KB
RevLine 
[8012]1## $Id: browser.py 8528 2012-05-26 10:46:13Z 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
[8460]37from waeup.fceokene.applicants.interfaces import (
[8247]38    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit,
[8520]39    ICustomApplicantOnlinePayment,
40    UG_OMIT_DISPLAY_FIELDS, PG_OMIT_DISPLAY_FIELDS,
41    UG_OMIT_MANAGE_FIELDS, PG_OMIT_MANAGE_FIELDS,
42    UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS)
[8460]43from waeup.fceokene.interfaces import MessageFactory as _
[8012]44
[8247]45#class RequestCallbackActionButton(RequestCallbackActionButton):
[8259]46#    """ Display the base package callback button in custom pages.
[8247]47#    """
[8259]48#    grok.context(ICustomApplicantOnlinePayment)
[8012]49
[8247]50#class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
[8259]51#    """ Activate callback simulation view
[8247]52#    """
[8259]53#    grok.context(ICustomApplicantOnlinePayment)
[8247]54
55class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
56    """A breadcrumb for payments.
[8012]57    """
[8247]58    grok.context(ICustomApplicantOnlinePayment)
[8012]59
[8259]60class PaymentReceiptActionButton(PaymentReceiptActionButton):
61    grok.order(4)
62    grok.context(ICustomApplicantOnlinePayment)
63
[8196]64class CustomPDFApplicationSlip(PDFApplicationSlip):
[8012]65
[8017]66    @property
67    def form_fields(self):
68        target = getattr(self.context.__parent__, 'prefix', None)
69        if target is not None and target.startswith('pg'):
[8520]70            form_fields = grok.AutoFields(IPGApplicant)
71            for field in PG_OMIT_DISPLAY_FIELDS:
72                form_fields = form_fields.omit(field)
[8017]73        else:
[8520]74            form_fields = grok.AutoFields(IUGApplicant)
75            for field in UG_OMIT_DISPLAY_FIELDS:
76                form_fields = form_fields.omit(field)
[8017]77        return form_fields
[8012]78
[8196]79class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
[8017]80    """A display view for applicant data.
81    """
[8012]82
83    @property
84    def form_fields(self):
85        target = getattr(self.context.__parent__, 'prefix', None)
86        if target is not None and target.startswith('pg'):
[8520]87            form_fields = grok.AutoFields(IPGApplicant)
88            for field in PG_OMIT_DISPLAY_FIELDS:
89                form_fields = form_fields.omit(field)
[8012]90        else:
[8520]91            form_fields = grok.AutoFields(IUGApplicant)
92            for field in UG_OMIT_DISPLAY_FIELDS:
93                form_fields = form_fields.omit(field)
[8012]94        return form_fields
95
[8196]96class CustomApplicantManageFormPage(ApplicantManageFormPage):
[8012]97    """A full edit view for applicant data.
98    """
[8017]99   
100    @property
101    def form_fields(self):
102        target = getattr(self.context.__parent__, 'prefix', None)
103        if target is not None and target.startswith('pg'):
104            form_fields = grok.AutoFields(IPGApplicant)
[8520]105            for field in PG_OMIT_MANAGE_FIELDS:
106                form_fields = form_fields.omit(field)
[8017]107        else:
108            form_fields = grok.AutoFields(IUGApplicant)
[8520]109            for field in UG_OMIT_MANAGE_FIELDS:
110                form_fields = form_fields.omit(field)
[8017]111        form_fields['student_id'].for_display = True
112        form_fields['applicant_id'].for_display = True
113        return form_fields
[8012]114
[8196]115class CustomApplicantEditFormPage(ApplicantEditFormPage):
[8012]116    """An applicant-centered edit view for applicant data.
117    """
[8017]118
119    @property
120    def form_fields(self):
121        target = getattr(self.context.__parent__, 'prefix', None)
122        if target is not None and target.startswith('pg'):
[8520]123            form_fields = grok.AutoFields(IPGApplicantEdit)
124            for field in PG_OMIT_EDIT_FIELDS:
125                form_fields = form_fields.omit(field)
[8017]126        else:
[8520]127            form_fields = grok.AutoFields(IUGApplicantEdit)
128            for field in UG_OMIT_EDIT_FIELDS:
129                form_fields = form_fields.omit(field)
[8017]130        form_fields['applicant_id'].for_display = True
[8051]131        form_fields['reg_number'].for_display = True
[8017]132        return form_fields
[8247]133
134class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
135    """ Page to view an online payment ticket
136    """
137    grok.context(ICustomApplicantOnlinePayment)
[8263]138    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
[8247]139    form_fields[
140        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
141    form_fields[
142        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
143    grok.template('payment_view')
144
145    @property
146    def transaction_code(self):
147        tcode = self.context.p_id
148        return tcode[len(tcode)-8:len(tcode)]
149
[8263]150class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
[8247]151    """ Page to add an online payment ticket
152    """
153    factory = u'waeup.CustomApplicantOnlinePayment'
154
[8259]155class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
156    """Deliver a PDF slip of the context.
157    """
158    grok.context(ICustomApplicantOnlinePayment)
[8292]159    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
[8259]160    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
161    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
162
163    @property
164    def note(self):
[8292]165        if self.context.p_state == 'paid':
166            return None
[8259]167        tcode = self.context.p_id
168        tcode = tcode[len(tcode)-8:len(tcode)]
169        amount = self.context.amount_auth
170        note = translate(_(
171            u"""<br /><br /><br />
[8520]172The tranzaction code is <strong>${a}</strong>.""",
[8259]173            mapping = {'a':tcode}))
174        return note
Note: See TracBrowser for help on using the repository browser.