[16717] | 1 | ## $Id: browser.py 17714 2024-03-11 11:28:19Z henrik $ |
---|
[15614] | 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 | """ |
---|
| 20 | import grok |
---|
[17711] | 21 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
| 22 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[15614] | 23 | from waeup.kofa.applicants.browser import ( |
---|
| 24 | ApplicantRegistrationPage, ApplicantsContainerPage) |
---|
[17711] | 25 | from waeup.kofa.applicants.browser import ( |
---|
[17714] | 26 | AdditionalFile, |
---|
[17711] | 27 | ApplicantDisplayFormPage, |
---|
| 28 | ApplicantManageFormPage, |
---|
| 29 | ApplicantEditFormPage, |
---|
| 30 | ApplicantRegistrationPage, |
---|
| 31 | OnlinePaymentDisplayFormPage, |
---|
| 32 | OnlinePaymentBreadcrumb, |
---|
| 33 | ExportPDFPaymentSlipPage, |
---|
| 34 | ) |
---|
| 35 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
[15614] | 36 | |
---|
[17689] | 37 | from kofacustom.udss.applicants.interfaces import ( |
---|
[17711] | 38 | ICustomUGApplicant, |
---|
| 39 | ICustomApplicant, |
---|
| 40 | ICustomUGApplicantEdit, |
---|
[16718] | 41 | ICustomApplicantOnlinePayment, |
---|
| 42 | ) |
---|
| 43 | |
---|
[17689] | 44 | from kofacustom.udss.interfaces import MessageFactory as _ |
---|
[15614] | 45 | |
---|
[17712] | 46 | OMIT_DISPLAY_FIELDS = ('locked', 'suspended',) |
---|
[17711] | 47 | |
---|
[17712] | 48 | UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + () |
---|
| 49 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS |
---|
| 50 | UG_OMIT_MANAGE_FIELDS = () |
---|
[17711] | 51 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
| 52 | 'student_id', |
---|
[17712] | 53 | 'notice') |
---|
[17711] | 54 | |
---|
| 55 | class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
| 56 | """A display view for applicant data. |
---|
| 57 | """ |
---|
| 58 | |
---|
| 59 | def _not_paid(self): |
---|
| 60 | return self.context.state in ('initialized', 'started',) |
---|
| 61 | |
---|
| 62 | @property |
---|
| 63 | def form_fields(self): |
---|
| 64 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 65 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 66 | form_fields = form_fields.omit(field) |
---|
| 67 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 68 | if not getattr(self.context, 'student_id'): |
---|
| 69 | form_fields = form_fields.omit('student_id') |
---|
| 70 | return form_fields |
---|
| 71 | |
---|
| 72 | class CustomPDFApplicationSlip(PDFApplicationSlip): |
---|
| 73 | |
---|
| 74 | def _addLoginInformation(self): |
---|
| 75 | """ We do no longer render login information on |
---|
| 76 | pdf application slips. |
---|
| 77 | """ |
---|
| 78 | return |
---|
| 79 | |
---|
| 80 | def _reduced_slip(self): |
---|
[17712] | 81 | return False |
---|
[17711] | 82 | |
---|
| 83 | @property |
---|
| 84 | def form_fields(self): |
---|
| 85 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 86 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 87 | form_fields = form_fields.omit(field) |
---|
| 88 | if not getattr(self.context, 'student_id'): |
---|
| 89 | form_fields = form_fields.omit('student_id') |
---|
| 90 | return form_fields |
---|
| 91 | |
---|
| 92 | class CustomApplicantManageFormPage(ApplicantManageFormPage): |
---|
| 93 | """A full edit view for applicant data. |
---|
| 94 | """ |
---|
| 95 | |
---|
| 96 | @property |
---|
| 97 | def form_fields(self): |
---|
| 98 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 99 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 100 | form_fields = form_fields.omit(field) |
---|
| 101 | form_fields['student_id'].for_display = True |
---|
| 102 | form_fields['applicant_id'].for_display = True |
---|
| 103 | return form_fields |
---|
| 104 | |
---|
| 105 | class CustomApplicantEditFormPage(ApplicantEditFormPage): |
---|
[16718] | 106 | """An applicant-centered edit view for applicant data. |
---|
| 107 | """ |
---|
| 108 | |
---|
[17711] | 109 | @property |
---|
| 110 | def form_fields(self): |
---|
| 111 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 112 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 113 | form_fields = form_fields.omit(field) |
---|
| 114 | form_fields['applicant_id'].for_display = True |
---|
| 115 | form_fields['reg_number'].for_display = True |
---|
| 116 | return form_fields |
---|
| 117 | |
---|
[16718] | 118 | def unremovable(self, ticket): |
---|
| 119 | return True |
---|
| 120 | |
---|
[17714] | 121 | |
---|
| 122 | class FirsttermResult(AdditionalFile): |
---|
| 123 | """Renders the pdf form extension for applicants. |
---|
| 124 | """ |
---|
| 125 | grok.name('firsttermresult') |
---|
| 126 | |
---|
| 127 | class BirthCertificate(AdditionalFile): |
---|
| 128 | """Renders the pdf form extension for applicants. |
---|
| 129 | """ |
---|
| 130 | grok.name('birthcertificate') |
---|