- Timestamp:
- 13 Sep 2022, 07:06:32 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.lpng/trunk/src/kofacustom/lpng/applicants/browser.py
r17073 r17091 26 26 FriendlyDatetimeDisplayWidget) 27 27 from waeup.kofa.applicants.pdf import PDFApplicationSlip 28 from waeup.kofa.browser.layout import KofaEditFormPage, action 28 29 from waeup.kofa.applicants.browser import ( 29 30 ApplicantRegistrationPage, ApplicantsContainerPage, … … 46 47 ICustomApplicantOnlinePayment, 47 48 ICustomApplicantEdit, 49 IPollingUnit, 50 STATES, LGAS, WARDS, PUNITS 48 51 ) 49 52 from kofacustom.lpng.interfaces import MessageFactory as _ … … 55 58 56 59 @property 57 def form_fields(self): 58 form_fields = grok.AutoFields(ICustomApplicant) 60 def render_punit(self): 61 if self.context.punit: 62 punit = self.context.punit.split('_') 63 return ' / '.join([STATES[punit[0]], 64 LGAS['_'.join(punit[:2])], 65 WARDS['_'.join(punit[:3])] , 66 PUNITS['_'.join(punit[:4])] 67 ]) 68 return 69 70 @property 71 def form_fields(self): 72 form_fields = grok.AutoFields( 73 ICustomApplicant).omit('locked', 'suspended', 'federalstate', 74 'lga', 'ward', 'punit') 59 75 form_fields['perm_address'].custom_widget = BytesDisplayWidget 60 form_fields['notice'].custom_widget = BytesDisplayWidget76 #form_fields['notice'].custom_widget = BytesDisplayWidget 61 77 if not getattr(self.context, 'student_id'): 62 78 form_fields = form_fields.omit('student_id') … … 91 107 @property 92 108 def form_fields(self): 93 form_fields = grok.AutoFields(ICustomApplicant) 109 form_fields = grok.AutoFields(ICustomApplicant).omit( 110 'federalstate', 'lga', 'ward', 'punit') 94 111 if not getattr(self.context, 'student_id'): 95 112 form_fields = form_fields.omit('student_id') … … 136 153 def form_fields(self): 137 154 form_fields = grok.AutoFields(ICustomApplicantEdit) 138 form_fields = form_fields.omit('notice', 'locked', 'suspended') 155 form_fields = form_fields.omit('locked', 'suspended', 'federalstate', 156 'lga', 'ward', 'punit') 139 157 if not getattr(self.context, 'student_id'): 140 158 form_fields = form_fields.omit('student_id') … … 177 195 self.context.__parent__, applicantview, note=self.note, 178 196 omit_fields=()) 197 198 class PunitFormPage(KofaEditFormPage): 199 """ 200 """ 201 grok.context(ICustomApplicant) 202 grok.require('waeup.handleApplication') 203 grok.name('punitformpage') 204 form_fields = grok.AutoFields(IPollingUnit) 205 grok.template('puniteditpage') 206 label = _('Locate polling unit') 207 pnav = 3 208 209 @action(_('Save'), style='primary') 210 def save(self, **data): 211 changed_fields = self.applyData(self.context, **data) 212 # Turn list of lists into single list 213 if changed_fields: 214 changed_fields = reduce(lambda x, y: x+y, changed_fields.values()) 215 if 'federalstate' in changed_fields: 216 # Clear other form fields 217 self.context.lga = self.context.ward = self.context.punit = None 218 self.flash(_('Federal State has been saved.')) 219 return 220 if 'lga' in changed_fields: 221 # Clear other form fields 222 self.context.ward = self.context.punit = None 223 self.flash(_('LGA has been saved.')) 224 return 225 if 'ward' in changed_fields: 226 # Clear other form fields 227 self.context.punit = None 228 self.flash(_('Ward has been saved.')) 229 return 230 if 'punit' in changed_fields and self.context.punit: 231 self.flash(_('Polling Unit has been successfully saved.')) 232 self.redirect(self.url(self.context)) 233 return
Note: See TracChangeset for help on using the changeset viewer.