[5273] | 1 | ## $Id: browser.py 13177 2015-07-18 06:07:14Z henrik $ |
---|
[6078] | 2 | ## |
---|
[7192] | 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
[5273] | 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. |
---|
[6078] | 8 | ## |
---|
[5273] | 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. |
---|
[6078] | 13 | ## |
---|
[5273] | 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 | ## |
---|
[5824] | 18 | """UI components for basic applicants and related components. |
---|
[5273] | 19 | """ |
---|
[7063] | 20 | import os |
---|
[6082] | 21 | import sys |
---|
[5273] | 22 | import grok |
---|
[7370] | 23 | from datetime import datetime, date |
---|
[8042] | 24 | from zope.event import notify |
---|
[13152] | 25 | from zope.component import getUtility, queryUtility, createObject, getAdapter |
---|
[8033] | 26 | from zope.catalog.interfaces import ICatalog |
---|
[7714] | 27 | from zope.i18n import translate |
---|
[7322] | 28 | from hurry.workflow.interfaces import ( |
---|
| 29 | IWorkflowInfo, IWorkflowState, InvalidTransitionError) |
---|
[7811] | 30 | from waeup.kofa.applicants.interfaces import ( |
---|
[7363] | 31 | IApplicant, IApplicantEdit, IApplicantsRoot, |
---|
[7683] | 32 | IApplicantsContainer, IApplicantsContainerAdd, |
---|
[8033] | 33 | MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils, |
---|
[10845] | 34 | IApplicantRegisterUpdate, ISpecialApplicant |
---|
[7363] | 35 | ) |
---|
[12247] | 36 | from waeup.kofa.utils.helpers import html2dict |
---|
[10655] | 37 | from waeup.kofa.applicants.container import ( |
---|
| 38 | ApplicantsContainer, VirtualApplicantsExportJobContainer) |
---|
[8404] | 39 | from waeup.kofa.applicants.applicant import search |
---|
[8636] | 40 | from waeup.kofa.applicants.workflow import ( |
---|
| 41 | INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED) |
---|
[7811] | 42 | from waeup.kofa.browser import ( |
---|
[9217] | 43 | # KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage, |
---|
[7363] | 44 | DEFAULT_PASSPORT_IMAGE_PATH) |
---|
[9217] | 45 | from waeup.kofa.browser.layout import ( |
---|
| 46 | KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage) |
---|
[7811] | 47 | from waeup.kofa.browser.interfaces import ICaptchaManager |
---|
| 48 | from waeup.kofa.browser.breadcrumbs import Breadcrumb |
---|
| 49 | from waeup.kofa.browser.layout import ( |
---|
[11437] | 50 | NullValidator, jsaction, action, UtilityView) |
---|
[10655] | 51 | from waeup.kofa.browser.pages import ( |
---|
| 52 | add_local_role, del_local_roles, doll_up, ExportCSVView) |
---|
[7811] | 53 | from waeup.kofa.interfaces import ( |
---|
[13177] | 54 | IKofaObject, ILocalRolesAssignable, IExtFileStore, IPDF, DOCLINK, |
---|
[7819] | 55 | IFileStoreNameChooser, IPasswordValidator, IUserAccount, IKofaUtils) |
---|
[7811] | 56 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
| 57 | from waeup.kofa.permissions import get_users_with_local_roles |
---|
| 58 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[8186] | 59 | from waeup.kofa.utils.helpers import string_from_bytes, file_size, now |
---|
[8170] | 60 | from waeup.kofa.widgets.datewidget import ( |
---|
[10831] | 61 | FriendlyDateDisplayWidget, |
---|
[8170] | 62 | FriendlyDatetimeDisplayWidget) |
---|
[5320] | 63 | |
---|
[7819] | 64 | grok.context(IKofaObject) # Make IKofaObject the default context |
---|
[5273] | 65 | |
---|
[11437] | 66 | WARNING = _('You can not edit your application records after final submission.' |
---|
| 67 | ' You really want to submit?') |
---|
[8550] | 68 | |
---|
[8388] | 69 | class ApplicantsRootPage(KofaDisplayFormPage): |
---|
[5822] | 70 | grok.context(IApplicantsRoot) |
---|
| 71 | grok.name('index') |
---|
[6153] | 72 | grok.require('waeup.Public') |
---|
[8388] | 73 | form_fields = grok.AutoFields(IApplicantsRoot) |
---|
[13076] | 74 | label = _('Applicants Section') |
---|
[5843] | 75 | pnav = 3 |
---|
[6012] | 76 | |
---|
| 77 | def update(self): |
---|
[6067] | 78 | super(ApplicantsRootPage, self).update() |
---|
[6012] | 79 | return |
---|
| 80 | |
---|
[8388] | 81 | @property |
---|
| 82 | def introduction(self): |
---|
| 83 | # Here we know that the cookie has been set |
---|
| 84 | lang = self.request.cookies.get('kofa.language') |
---|
| 85 | html = self.context.description_dict.get(lang,'') |
---|
| 86 | if html == '': |
---|
| 87 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 88 | html = self.context.description_dict.get(portal_language,'') |
---|
| 89 | return html |
---|
| 90 | |
---|
[10097] | 91 | @property |
---|
| 92 | def containers(self): |
---|
[10098] | 93 | if self.layout.isAuthenticated(): |
---|
| 94 | return self.context.values() |
---|
[10097] | 95 | return [value for value in self.context.values() if not value.hidden] |
---|
| 96 | |
---|
[8404] | 97 | class ApplicantsSearchPage(KofaPage): |
---|
| 98 | grok.context(IApplicantsRoot) |
---|
| 99 | grok.name('search') |
---|
| 100 | grok.require('waeup.viewApplication') |
---|
[10644] | 101 | label = _('Find applicants') |
---|
[10645] | 102 | search_button = _('Find applicant') |
---|
[8404] | 103 | pnav = 3 |
---|
| 104 | |
---|
| 105 | def update(self, *args, **kw): |
---|
| 106 | form = self.request.form |
---|
| 107 | self.results = [] |
---|
| 108 | if 'searchterm' in form and form['searchterm']: |
---|
| 109 | self.searchterm = form['searchterm'] |
---|
| 110 | self.searchtype = form['searchtype'] |
---|
| 111 | elif 'old_searchterm' in form: |
---|
| 112 | self.searchterm = form['old_searchterm'] |
---|
| 113 | self.searchtype = form['old_searchtype'] |
---|
| 114 | else: |
---|
| 115 | if 'search' in form: |
---|
[11254] | 116 | self.flash(_('Empty search string'), type='warning') |
---|
[8404] | 117 | return |
---|
| 118 | self.results = search(query=self.searchterm, |
---|
| 119 | searchtype=self.searchtype, view=self) |
---|
| 120 | if not self.results: |
---|
[11254] | 121 | self.flash(_('No applicant found.'), type='warning') |
---|
[8404] | 122 | return |
---|
| 123 | |
---|
[7819] | 124 | class ApplicantsRootManageFormPage(KofaEditFormPage): |
---|
[5828] | 125 | grok.context(IApplicantsRoot) |
---|
| 126 | grok.name('manage') |
---|
[6107] | 127 | grok.template('applicantsrootmanagepage') |
---|
[8388] | 128 | form_fields = grok.AutoFields(IApplicantsRoot) |
---|
[13076] | 129 | label = _('Manage applicants section') |
---|
[5843] | 130 | pnav = 3 |
---|
[7136] | 131 | grok.require('waeup.manageApplication') |
---|
[8388] | 132 | taboneactions = [_('Save')] |
---|
| 133 | tabtwoactions = [_('Add applicants container'), _('Remove selected')] |
---|
| 134 | tabthreeactions1 = [_('Remove selected local roles')] |
---|
| 135 | tabthreeactions2 = [_('Add local role')] |
---|
[7710] | 136 | subunits = _('Applicants Containers') |
---|
[13177] | 137 | doclink = DOCLINK + '/applicants.html' |
---|
[6078] | 138 | |
---|
[6184] | 139 | def getLocalRoles(self): |
---|
| 140 | roles = ILocalRolesAssignable(self.context) |
---|
| 141 | return roles() |
---|
| 142 | |
---|
| 143 | def getUsers(self): |
---|
| 144 | """Get a list of all users. |
---|
| 145 | """ |
---|
| 146 | for key, val in grok.getSite()['users'].items(): |
---|
| 147 | url = self.url(val) |
---|
| 148 | yield(dict(url=url, name=key, val=val)) |
---|
| 149 | |
---|
| 150 | def getUsersWithLocalRoles(self): |
---|
| 151 | return get_users_with_local_roles(self.context) |
---|
| 152 | |
---|
[7710] | 153 | @jsaction(_('Remove selected')) |
---|
[6069] | 154 | def delApplicantsContainers(self, **data): |
---|
| 155 | form = self.request.form |
---|
[9701] | 156 | if 'val_id' in form: |
---|
[8388] | 157 | child_id = form['val_id'] |
---|
| 158 | else: |
---|
[11254] | 159 | self.flash(_('No container selected!'), type='warning') |
---|
| 160 | self.redirect(self.url(self.context, '@@manage')+'#tab2') |
---|
[8388] | 161 | return |
---|
[6069] | 162 | if not isinstance(child_id, list): |
---|
| 163 | child_id = [child_id] |
---|
| 164 | deleted = [] |
---|
| 165 | for id in child_id: |
---|
| 166 | try: |
---|
| 167 | del self.context[id] |
---|
| 168 | deleted.append(id) |
---|
| 169 | except: |
---|
[7710] | 170 | self.flash(_('Could not delete:') + ' %s: %s: %s' % ( |
---|
[11254] | 171 | id, sys.exc_info()[0], sys.exc_info()[1]), type='danger') |
---|
[6069] | 172 | if len(deleted): |
---|
[7738] | 173 | self.flash(_('Successfully removed: ${a}', |
---|
| 174 | mapping = {'a':', '.join(deleted)})) |
---|
[12892] | 175 | ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') |
---|
| 176 | self.context.logger.info( |
---|
| 177 | '%s - removed: %s' % (ob_class, ', '.join(deleted))) |
---|
[11254] | 178 | self.redirect(self.url(self.context, '@@manage')+'#tab2') |
---|
[6078] | 179 | return |
---|
[5828] | 180 | |
---|
[7710] | 181 | @action(_('Add applicants container'), validator=NullValidator) |
---|
[6069] | 182 | def addApplicantsContainer(self, **data): |
---|
| 183 | self.redirect(self.url(self.context, '@@add')) |
---|
[6078] | 184 | return |
---|
| 185 | |
---|
[7710] | 186 | @action(_('Add local role'), validator=NullValidator) |
---|
[6184] | 187 | def addLocalRole(self, **data): |
---|
[7484] | 188 | return add_local_role(self,3, **data) |
---|
[6184] | 189 | |
---|
[7710] | 190 | @action(_('Remove selected local roles')) |
---|
[6184] | 191 | def delLocalRoles(self, **data): |
---|
[7484] | 192 | return del_local_roles(self,3,**data) |
---|
[6184] | 193 | |
---|
[8388] | 194 | @action(_('Save'), style='primary') |
---|
| 195 | def save(self, **data): |
---|
| 196 | self.applyData(self.context, **data) |
---|
[12247] | 197 | description = getattr(self.context, 'description', None) |
---|
| 198 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 199 | self.context.description_dict = html2dict(description, portal_language) |
---|
[8390] | 200 | self.flash(_('Form has been saved.')) |
---|
[8388] | 201 | return |
---|
| 202 | |
---|
[7819] | 203 | class ApplicantsContainerAddFormPage(KofaAddFormPage): |
---|
[5822] | 204 | grok.context(IApplicantsRoot) |
---|
[7136] | 205 | grok.require('waeup.manageApplication') |
---|
[5822] | 206 | grok.name('add') |
---|
[6107] | 207 | grok.template('applicantscontaineraddpage') |
---|
[7710] | 208 | label = _('Add applicants container') |
---|
[5843] | 209 | pnav = 3 |
---|
[6078] | 210 | |
---|
[6103] | 211 | form_fields = grok.AutoFields( |
---|
[7903] | 212 | IApplicantsContainerAdd).omit('code').omit('title') |
---|
[6078] | 213 | |
---|
[7710] | 214 | @action(_('Add applicants container')) |
---|
[6069] | 215 | def addApplicantsContainer(self, **data): |
---|
[6103] | 216 | year = data['year'] |
---|
| 217 | code = u'%s%s' % (data['prefix'], year) |
---|
[9529] | 218 | apptypes_dict = getUtility(IApplicantsUtils).APP_TYPES_DICT |
---|
| 219 | title = apptypes_dict[data['prefix']][0] |
---|
[7685] | 220 | title = u'%s %s/%s' % (title, year, year + 1) |
---|
[6087] | 221 | if code in self.context.keys(): |
---|
[6105] | 222 | self.flash( |
---|
[11254] | 223 | _('An applicants container for the same application ' |
---|
| 224 | 'type and entrance year exists already in the database.'), |
---|
| 225 | type='warning') |
---|
[5822] | 226 | return |
---|
| 227 | # Add new applicants container... |
---|
[8009] | 228 | container = createObject(u'waeup.ApplicantsContainer') |
---|
[6069] | 229 | self.applyData(container, **data) |
---|
[6087] | 230 | container.code = code |
---|
| 231 | container.title = title |
---|
| 232 | self.context[code] = container |
---|
[7710] | 233 | self.flash(_('Added:') + ' "%s".' % code) |
---|
[12892] | 234 | ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') |
---|
| 235 | self.context.logger.info('%s - added: %s' % (ob_class, code)) |
---|
[7484] | 236 | self.redirect(self.url(self.context, u'@@manage')) |
---|
[5822] | 237 | return |
---|
[6078] | 238 | |
---|
[7710] | 239 | @action(_('Cancel'), validator=NullValidator) |
---|
[6069] | 240 | def cancel(self, **data): |
---|
[7484] | 241 | self.redirect(self.url(self.context, '@@manage')) |
---|
[6078] | 242 | |
---|
[5845] | 243 | class ApplicantsRootBreadcrumb(Breadcrumb): |
---|
| 244 | """A breadcrumb for applicantsroot. |
---|
| 245 | """ |
---|
| 246 | grok.context(IApplicantsRoot) |
---|
[7710] | 247 | title = _(u'Applicants') |
---|
[6078] | 248 | |
---|
[5845] | 249 | class ApplicantsContainerBreadcrumb(Breadcrumb): |
---|
| 250 | """A breadcrumb for applicantscontainers. |
---|
| 251 | """ |
---|
| 252 | grok.context(IApplicantsContainer) |
---|
[6319] | 253 | |
---|
[10655] | 254 | |
---|
| 255 | class ApplicantsExportsBreadcrumb(Breadcrumb): |
---|
| 256 | """A breadcrumb for exports. |
---|
| 257 | """ |
---|
| 258 | grok.context(VirtualApplicantsExportJobContainer) |
---|
| 259 | title = _(u'Applicant Data Exports') |
---|
| 260 | target = None |
---|
| 261 | |
---|
[6153] | 262 | class ApplicantBreadcrumb(Breadcrumb): |
---|
| 263 | """A breadcrumb for applicants. |
---|
| 264 | """ |
---|
| 265 | grok.context(IApplicant) |
---|
[6319] | 266 | |
---|
[6153] | 267 | @property |
---|
| 268 | def title(self): |
---|
| 269 | """Get a title for a context. |
---|
| 270 | """ |
---|
[7240] | 271 | return self.context.application_number |
---|
[5828] | 272 | |
---|
[7250] | 273 | class OnlinePaymentBreadcrumb(Breadcrumb): |
---|
| 274 | """A breadcrumb for payments. |
---|
| 275 | """ |
---|
| 276 | grok.context(IApplicantOnlinePayment) |
---|
| 277 | |
---|
| 278 | @property |
---|
| 279 | def title(self): |
---|
| 280 | return self.context.p_id |
---|
| 281 | |
---|
[8563] | 282 | class ApplicantsStatisticsPage(KofaDisplayFormPage): |
---|
| 283 | """Some statistics about applicants in a container. |
---|
| 284 | """ |
---|
| 285 | grok.context(IApplicantsContainer) |
---|
| 286 | grok.name('statistics') |
---|
[8565] | 287 | grok.require('waeup.viewApplicationStatistics') |
---|
[8563] | 288 | grok.template('applicantcontainerstatistics') |
---|
| 289 | |
---|
| 290 | @property |
---|
| 291 | def label(self): |
---|
| 292 | return "%s" % self.context.title |
---|
| 293 | |
---|
[7819] | 294 | class ApplicantsContainerPage(KofaDisplayFormPage): |
---|
[5830] | 295 | """The standard view for regular applicant containers. |
---|
| 296 | """ |
---|
| 297 | grok.context(IApplicantsContainer) |
---|
| 298 | grok.name('index') |
---|
[6153] | 299 | grok.require('waeup.Public') |
---|
[6029] | 300 | grok.template('applicantscontainerpage') |
---|
[5850] | 301 | pnav = 3 |
---|
[6053] | 302 | |
---|
[9078] | 303 | @property |
---|
| 304 | def form_fields(self): |
---|
[12247] | 305 | form_fields = grok.AutoFields(IApplicantsContainer).omit( |
---|
| 306 | 'title', 'description') |
---|
[9078] | 307 | form_fields[ |
---|
| 308 | 'startdate'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 309 | form_fields[ |
---|
| 310 | 'enddate'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 311 | if self.request.principal.id == 'zope.anybody': |
---|
| 312 | form_fields = form_fields.omit( |
---|
[10101] | 313 | 'code', 'prefix', 'year', 'mode', 'hidden', |
---|
[11870] | 314 | 'strict_deadline', 'application_category', |
---|
| 315 | 'application_slip_notice') |
---|
[9078] | 316 | return form_fields |
---|
[6053] | 317 | |
---|
[5837] | 318 | @property |
---|
[7708] | 319 | def introduction(self): |
---|
[7833] | 320 | # Here we know that the cookie has been set |
---|
| 321 | lang = self.request.cookies.get('kofa.language') |
---|
[7708] | 322 | html = self.context.description_dict.get(lang,'') |
---|
[8388] | 323 | if html == '': |
---|
[7833] | 324 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[7708] | 325 | html = self.context.description_dict.get(portal_language,'') |
---|
[8388] | 326 | return html |
---|
[7708] | 327 | |
---|
| 328 | @property |
---|
[7467] | 329 | def label(self): |
---|
[7493] | 330 | return "%s" % self.context.title |
---|
[5837] | 331 | |
---|
[7819] | 332 | class ApplicantsContainerManageFormPage(KofaEditFormPage): |
---|
[5837] | 333 | grok.context(IApplicantsContainer) |
---|
[5850] | 334 | grok.name('manage') |
---|
[6107] | 335 | grok.template('applicantscontainermanagepage') |
---|
[10625] | 336 | form_fields = grok.AutoFields(IApplicantsContainer) |
---|
[7710] | 337 | taboneactions = [_('Save'),_('Cancel')] |
---|
[8684] | 338 | tabtwoactions = [_('Remove selected'),_('Cancel'), |
---|
[8314] | 339 | _('Create students from selected')] |
---|
[7710] | 340 | tabthreeactions1 = [_('Remove selected local roles')] |
---|
| 341 | tabthreeactions2 = [_('Add local role')] |
---|
[5844] | 342 | # Use friendlier date widget... |
---|
[7136] | 343 | grok.require('waeup.manageApplication') |
---|
[13177] | 344 | doclink = DOCLINK + '/applicants.html' |
---|
[5850] | 345 | |
---|
| 346 | @property |
---|
| 347 | def label(self): |
---|
[7710] | 348 | return _('Manage applicants container') |
---|
[5850] | 349 | |
---|
[5845] | 350 | pnav = 3 |
---|
[5837] | 351 | |
---|
[8547] | 352 | @property |
---|
| 353 | def showApplicants(self): |
---|
| 354 | if len(self.context) < 5000: |
---|
| 355 | return True |
---|
| 356 | return False |
---|
| 357 | |
---|
[6184] | 358 | def getLocalRoles(self): |
---|
| 359 | roles = ILocalRolesAssignable(self.context) |
---|
| 360 | return roles() |
---|
| 361 | |
---|
| 362 | def getUsers(self): |
---|
| 363 | """Get a list of all users. |
---|
| 364 | """ |
---|
| 365 | for key, val in grok.getSite()['users'].items(): |
---|
| 366 | url = self.url(val) |
---|
| 367 | yield(dict(url=url, name=key, val=val)) |
---|
| 368 | |
---|
| 369 | def getUsersWithLocalRoles(self): |
---|
| 370 | return get_users_with_local_roles(self.context) |
---|
| 371 | |
---|
[7714] | 372 | @action(_('Save'), style='primary') |
---|
[7489] | 373 | def save(self, **data): |
---|
[9531] | 374 | changed_fields = self.applyData(self.context, **data) |
---|
| 375 | if changed_fields: |
---|
| 376 | changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) |
---|
| 377 | else: |
---|
| 378 | changed_fields = [] |
---|
[12247] | 379 | description = getattr(self.context, 'description', None) |
---|
| 380 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 381 | self.context.description_dict = html2dict(description, portal_language) |
---|
[7710] | 382 | self.flash(_('Form has been saved.')) |
---|
[9531] | 383 | fields_string = ' + '.join(changed_fields) |
---|
[12892] | 384 | self.context.writeLogMessage(self, 'saved: %s' % fields_string) |
---|
[5837] | 385 | return |
---|
[6078] | 386 | |
---|
[7710] | 387 | @jsaction(_('Remove selected')) |
---|
[6105] | 388 | def delApplicant(self, **data): |
---|
[6189] | 389 | form = self.request.form |
---|
[9701] | 390 | if 'val_id' in form: |
---|
[6189] | 391 | child_id = form['val_id'] |
---|
| 392 | else: |
---|
[11254] | 393 | self.flash(_('No applicant selected!'), type='warning') |
---|
| 394 | self.redirect(self.url(self.context, '@@manage')+'#tab2') |
---|
[6189] | 395 | return |
---|
| 396 | if not isinstance(child_id, list): |
---|
| 397 | child_id = [child_id] |
---|
| 398 | deleted = [] |
---|
| 399 | for id in child_id: |
---|
| 400 | try: |
---|
| 401 | del self.context[id] |
---|
| 402 | deleted.append(id) |
---|
| 403 | except: |
---|
[7710] | 404 | self.flash(_('Could not delete:') + ' %s: %s: %s' % ( |
---|
[11254] | 405 | id, sys.exc_info()[0], sys.exc_info()[1]), type='danger') |
---|
[6189] | 406 | if len(deleted): |
---|
[7741] | 407 | self.flash(_('Successfully removed: ${a}', |
---|
[7738] | 408 | mapping = {'a':', '.join(deleted)})) |
---|
[11254] | 409 | self.redirect(self.url(self.context, u'@@manage')+'#tab2') |
---|
[6189] | 410 | return |
---|
[6105] | 411 | |
---|
[8314] | 412 | @action(_('Create students from selected')) |
---|
| 413 | def createStudents(self, **data): |
---|
| 414 | form = self.request.form |
---|
[9701] | 415 | if 'val_id' in form: |
---|
[8314] | 416 | child_id = form['val_id'] |
---|
| 417 | else: |
---|
[11254] | 418 | self.flash(_('No applicant selected!'), type='warning') |
---|
| 419 | self.redirect(self.url(self.context, '@@manage')+'#tab2') |
---|
[8314] | 420 | return |
---|
| 421 | if not isinstance(child_id, list): |
---|
| 422 | child_id = [child_id] |
---|
| 423 | created = [] |
---|
| 424 | for id in child_id: |
---|
| 425 | success, msg = self.context[id].createStudent(view=self) |
---|
| 426 | if success: |
---|
| 427 | created.append(id) |
---|
| 428 | if len(created): |
---|
| 429 | self.flash(_('${a} students successfully created.', |
---|
| 430 | mapping = {'a': len(created)})) |
---|
| 431 | else: |
---|
[11254] | 432 | self.flash(_('No student could be created.'), type='warning') |
---|
| 433 | self.redirect(self.url(self.context, u'@@manage')+'#tab2') |
---|
[8314] | 434 | return |
---|
| 435 | |
---|
[7710] | 436 | @action(_('Cancel'), validator=NullValidator) |
---|
[5837] | 437 | def cancel(self, **data): |
---|
| 438 | self.redirect(self.url(self.context)) |
---|
| 439 | return |
---|
[5886] | 440 | |
---|
[7710] | 441 | @action(_('Add local role'), validator=NullValidator) |
---|
[6184] | 442 | def addLocalRole(self, **data): |
---|
| 443 | return add_local_role(self,3, **data) |
---|
[6105] | 444 | |
---|
[7710] | 445 | @action(_('Remove selected local roles')) |
---|
[6184] | 446 | def delLocalRoles(self, **data): |
---|
| 447 | return del_local_roles(self,3,**data) |
---|
| 448 | |
---|
[7819] | 449 | class ApplicantAddFormPage(KofaAddFormPage): |
---|
[6622] | 450 | """Add-form to add an applicant. |
---|
[6327] | 451 | """ |
---|
| 452 | grok.context(IApplicantsContainer) |
---|
[7136] | 453 | grok.require('waeup.manageApplication') |
---|
[6327] | 454 | grok.name('addapplicant') |
---|
[7240] | 455 | #grok.template('applicantaddpage') |
---|
| 456 | form_fields = grok.AutoFields(IApplicant).select( |
---|
[7356] | 457 | 'firstname', 'middlename', 'lastname', |
---|
[7240] | 458 | 'email', 'phone') |
---|
[7714] | 459 | label = _('Add applicant') |
---|
[6327] | 460 | pnav = 3 |
---|
[13177] | 461 | doclink = DOCLINK + '/applicants.html' |
---|
[6327] | 462 | |
---|
[7714] | 463 | @action(_('Create application record')) |
---|
[6327] | 464 | def addApplicant(self, **data): |
---|
[8008] | 465 | applicant = createObject(u'waeup.Applicant') |
---|
[7240] | 466 | self.applyData(applicant, **data) |
---|
| 467 | self.context.addApplicant(applicant) |
---|
[13073] | 468 | self.flash(_('Application record created.')) |
---|
[7363] | 469 | self.redirect( |
---|
| 470 | self.url(self.context[applicant.application_number], 'index')) |
---|
[6327] | 471 | return |
---|
| 472 | |
---|
[7819] | 473 | class ApplicantDisplayFormPage(KofaDisplayFormPage): |
---|
[8014] | 474 | """A display view for applicant data. |
---|
| 475 | """ |
---|
[5273] | 476 | grok.context(IApplicant) |
---|
| 477 | grok.name('index') |
---|
[7113] | 478 | grok.require('waeup.viewApplication') |
---|
[7200] | 479 | grok.template('applicantdisplaypage') |
---|
[7714] | 480 | label = _('Applicant') |
---|
[5843] | 481 | pnav = 3 |
---|
[8922] | 482 | hide_hint = False |
---|
[5273] | 483 | |
---|
[8046] | 484 | @property |
---|
[10831] | 485 | def form_fields(self): |
---|
| 486 | if self.context.special: |
---|
[11599] | 487 | form_fields = grok.AutoFields(ISpecialApplicant).omit('locked') |
---|
[10831] | 488 | else: |
---|
| 489 | form_fields = grok.AutoFields(IApplicant).omit( |
---|
[10845] | 490 | 'locked', 'course_admitted', 'password', 'suspended') |
---|
[10831] | 491 | return form_fields |
---|
| 492 | |
---|
| 493 | @property |
---|
[10534] | 494 | def target(self): |
---|
| 495 | return getattr(self.context.__parent__, 'prefix', None) |
---|
| 496 | |
---|
| 497 | @property |
---|
[8046] | 498 | def separators(self): |
---|
| 499 | return getUtility(IApplicantsUtils).SEPARATORS_DICT |
---|
| 500 | |
---|
[7063] | 501 | def update(self): |
---|
| 502 | self.passport_url = self.url(self.context, 'passport.jpg') |
---|
[7240] | 503 | # Mark application as started if applicant logs in for the first time |
---|
[7272] | 504 | usertype = getattr(self.request.principal, 'user_type', None) |
---|
| 505 | if usertype == 'applicant' and \ |
---|
| 506 | IWorkflowState(self.context).getState() == INITIALIZED: |
---|
[7240] | 507 | IWorkflowInfo(self.context).fireTransition('start') |
---|
[10895] | 508 | if usertype == 'applicant' and self.context.state == 'created': |
---|
[10908] | 509 | session = '%s/%s' % (self.context.__parent__.year, |
---|
| 510 | self.context.__parent__.year+1) |
---|
| 511 | title = getattr(grok.getSite()['configuration'], 'name', u'Sample University') |
---|
[10895] | 512 | msg = _( |
---|
| 513 | '\n <strong>Congratulations!</strong>' + |
---|
[10933] | 514 | ' You have been offered provisional admission into the' + |
---|
[10908] | 515 | ' ${c} Academic Session of ${d}.' |
---|
| 516 | ' Your student record has been created for you.' + |
---|
| 517 | ' Please, logout again and proceed to the' + |
---|
| 518 | ' login page of the portal.' |
---|
[10895] | 519 | ' Then enter your new student credentials:' + |
---|
| 520 | ' user name= ${a}, password = ${b}.' + |
---|
| 521 | ' Change your password when you have logged in.', |
---|
| 522 | mapping = { |
---|
| 523 | 'a':self.context.student_id, |
---|
[10908] | 524 | 'b':self.context.application_number, |
---|
| 525 | 'c':session, |
---|
| 526 | 'd':title} |
---|
[10895] | 527 | ) |
---|
| 528 | self.flash(msg) |
---|
[7063] | 529 | return |
---|
| 530 | |
---|
[6196] | 531 | @property |
---|
[7240] | 532 | def hasPassword(self): |
---|
| 533 | if self.context.password: |
---|
[7714] | 534 | return _('set') |
---|
| 535 | return _('unset') |
---|
[7240] | 536 | |
---|
| 537 | @property |
---|
[6196] | 538 | def label(self): |
---|
| 539 | container_title = self.context.__parent__.title |
---|
[8096] | 540 | return _('${a} <br /> Application Record ${b}', mapping = { |
---|
[7714] | 541 | 'a':container_title, 'b':self.context.application_number}) |
---|
[6196] | 542 | |
---|
[7347] | 543 | def getCourseAdmitted(self): |
---|
| 544 | """Return link, title and code in html format to the certificate |
---|
| 545 | admitted. |
---|
| 546 | """ |
---|
| 547 | course_admitted = self.context.course_admitted |
---|
[7351] | 548 | if getattr(course_admitted, '__parent__',None): |
---|
[7347] | 549 | url = self.url(course_admitted) |
---|
| 550 | title = course_admitted.title |
---|
| 551 | code = course_admitted.code |
---|
| 552 | return '<a href="%s">%s - %s</a>' %(url,code,title) |
---|
| 553 | return '' |
---|
[6254] | 554 | |
---|
[7259] | 555 | class ApplicantBaseDisplayFormPage(ApplicantDisplayFormPage): |
---|
| 556 | grok.context(IApplicant) |
---|
| 557 | grok.name('base') |
---|
| 558 | form_fields = grok.AutoFields(IApplicant).select( |
---|
[9141] | 559 | 'applicant_id','email', 'course1') |
---|
[7259] | 560 | |
---|
[7459] | 561 | class CreateStudentPage(UtilityView, grok.View): |
---|
[8636] | 562 | """Create a student object from applicant data. |
---|
[7341] | 563 | """ |
---|
| 564 | grok.context(IApplicant) |
---|
| 565 | grok.name('createstudent') |
---|
| 566 | grok.require('waeup.manageStudent') |
---|
| 567 | |
---|
| 568 | def update(self): |
---|
[8314] | 569 | msg = self.context.createStudent(view=self)[1] |
---|
[11254] | 570 | self.flash(msg, type='warning') |
---|
[7341] | 571 | self.redirect(self.url(self.context)) |
---|
| 572 | return |
---|
| 573 | |
---|
| 574 | def render(self): |
---|
| 575 | return |
---|
| 576 | |
---|
[8636] | 577 | class CreateAllStudentsPage(UtilityView, grok.View): |
---|
| 578 | """Create all student objects from applicant data |
---|
[11874] | 579 | in the root container or in a specific applicants container only. |
---|
[11826] | 580 | Only PortalManagers can do this. |
---|
[8636] | 581 | """ |
---|
[9900] | 582 | #grok.context(IApplicantsContainer) |
---|
[8636] | 583 | grok.name('createallstudents') |
---|
| 584 | grok.require('waeup.managePortal') |
---|
| 585 | |
---|
| 586 | def update(self): |
---|
| 587 | cat = getUtility(ICatalog, name='applicants_catalog') |
---|
| 588 | results = list(cat.searchResults(state=(ADMITTED, ADMITTED))) |
---|
| 589 | created = [] |
---|
[9900] | 590 | container_only = False |
---|
| 591 | applicants_root = grok.getSite()['applicants'] |
---|
| 592 | if isinstance(self.context, ApplicantsContainer): |
---|
| 593 | container_only = True |
---|
[8636] | 594 | for result in results: |
---|
[9900] | 595 | if container_only and result.__parent__ is not self.context: |
---|
[8636] | 596 | continue |
---|
| 597 | success, msg = result.createStudent(view=self) |
---|
| 598 | if success: |
---|
| 599 | created.append(result.applicant_id) |
---|
| 600 | else: |
---|
[12893] | 601 | ob_class = self.__implemented__.__name__.replace( |
---|
| 602 | 'waeup.kofa.','') |
---|
[9900] | 603 | applicants_root.logger.info( |
---|
[8742] | 604 | '%s - %s - %s' % (ob_class, result.applicant_id, msg)) |
---|
[8636] | 605 | if len(created): |
---|
| 606 | self.flash(_('${a} students successfully created.', |
---|
| 607 | mapping = {'a': len(created)})) |
---|
| 608 | else: |
---|
[11254] | 609 | self.flash(_('No student could be created.'), type='warning') |
---|
[9900] | 610 | self.redirect(self.url(self.context)) |
---|
[8636] | 611 | return |
---|
| 612 | |
---|
| 613 | def render(self): |
---|
| 614 | return |
---|
| 615 | |
---|
[8260] | 616 | class ApplicationFeePaymentAddPage(UtilityView, grok.View): |
---|
[7250] | 617 | """ Page to add an online payment ticket |
---|
| 618 | """ |
---|
| 619 | grok.context(IApplicant) |
---|
| 620 | grok.name('addafp') |
---|
| 621 | grok.require('waeup.payApplicant') |
---|
[8243] | 622 | factory = u'waeup.ApplicantOnlinePayment' |
---|
[7250] | 623 | |
---|
[11726] | 624 | @property |
---|
| 625 | def custom_requirements(self): |
---|
| 626 | return '' |
---|
| 627 | |
---|
[7250] | 628 | def update(self): |
---|
[11726] | 629 | # Additional requirements in custom packages. |
---|
| 630 | if self.custom_requirements: |
---|
| 631 | self.flash( |
---|
| 632 | self.custom_requirements, |
---|
| 633 | type='danger') |
---|
| 634 | self.redirect(self.url(self.context)) |
---|
[11727] | 635 | return |
---|
[11575] | 636 | if not self.context.special: |
---|
| 637 | for key in self.context.keys(): |
---|
| 638 | ticket = self.context[key] |
---|
| 639 | if ticket.p_state == 'paid': |
---|
| 640 | self.flash( |
---|
| 641 | _('This type of payment has already been made.'), |
---|
| 642 | type='warning') |
---|
| 643 | self.redirect(self.url(self.context)) |
---|
| 644 | return |
---|
[8524] | 645 | applicants_utils = getUtility(IApplicantsUtils) |
---|
| 646 | container = self.context.__parent__ |
---|
[8243] | 647 | payment = createObject(self.factory) |
---|
[11254] | 648 | failure = applicants_utils.setPaymentDetails( |
---|
[10831] | 649 | container, payment, self.context) |
---|
[11254] | 650 | if failure is not None: |
---|
[13123] | 651 | self.flash(failure, type='danger') |
---|
[8524] | 652 | self.redirect(self.url(self.context)) |
---|
| 653 | return |
---|
[7250] | 654 | self.context[payment.p_id] = payment |
---|
[12893] | 655 | self.context.writeLogMessage(self, 'added: %s' % payment.p_id) |
---|
[7714] | 656 | self.flash(_('Payment ticket created.')) |
---|
[8280] | 657 | self.redirect(self.url(payment)) |
---|
[7250] | 658 | return |
---|
| 659 | |
---|
| 660 | def render(self): |
---|
| 661 | return |
---|
| 662 | |
---|
| 663 | |
---|
[7819] | 664 | class OnlinePaymentDisplayFormPage(KofaDisplayFormPage): |
---|
[7250] | 665 | """ Page to view an online payment ticket |
---|
| 666 | """ |
---|
| 667 | grok.context(IApplicantOnlinePayment) |
---|
| 668 | grok.name('index') |
---|
| 669 | grok.require('waeup.viewApplication') |
---|
[9984] | 670 | form_fields = grok.AutoFields(IApplicantOnlinePayment).omit('p_item') |
---|
[8170] | 671 | form_fields[ |
---|
| 672 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 673 | form_fields[ |
---|
| 674 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[7250] | 675 | pnav = 3 |
---|
| 676 | |
---|
| 677 | @property |
---|
| 678 | def label(self): |
---|
[7714] | 679 | return _('${a}: Online Payment Ticket ${b}', mapping = { |
---|
[8170] | 680 | 'a':self.context.__parent__.display_fullname, |
---|
| 681 | 'b':self.context.p_id}) |
---|
[7250] | 682 | |
---|
[8420] | 683 | class OnlinePaymentApprovePage(UtilityView, grok.View): |
---|
| 684 | """ Approval view |
---|
[7250] | 685 | """ |
---|
| 686 | grok.context(IApplicantOnlinePayment) |
---|
[8420] | 687 | grok.name('approve') |
---|
| 688 | grok.require('waeup.managePortal') |
---|
[7250] | 689 | |
---|
| 690 | def update(self): |
---|
[11580] | 691 | flashtype, msg, log = self.context.approveApplicantPayment() |
---|
[8428] | 692 | if log is not None: |
---|
[9771] | 693 | applicant = self.context.__parent__ |
---|
| 694 | # Add log message to applicants.log |
---|
| 695 | applicant.writeLogMessage(self, log) |
---|
| 696 | # Add log message to payments.log |
---|
| 697 | self.context.logger.info( |
---|
[9795] | 698 | '%s,%s,%s,%s,%s,,,,,,' % ( |
---|
[9771] | 699 | applicant.applicant_id, |
---|
| 700 | self.context.p_id, self.context.p_category, |
---|
| 701 | self.context.amount_auth, self.context.r_code)) |
---|
[11580] | 702 | self.flash(msg, type=flashtype) |
---|
[7250] | 703 | return |
---|
| 704 | |
---|
| 705 | def render(self): |
---|
| 706 | self.redirect(self.url(self.context, '@@index')) |
---|
| 707 | return |
---|
| 708 | |
---|
[7459] | 709 | class ExportPDFPaymentSlipPage(UtilityView, grok.View): |
---|
[7250] | 710 | """Deliver a PDF slip of the context. |
---|
| 711 | """ |
---|
| 712 | grok.context(IApplicantOnlinePayment) |
---|
[8262] | 713 | grok.name('payment_slip.pdf') |
---|
[7250] | 714 | grok.require('waeup.viewApplication') |
---|
[9984] | 715 | form_fields = grok.AutoFields(IApplicantOnlinePayment).omit('p_item') |
---|
[8173] | 716 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 717 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[7250] | 718 | prefix = 'form' |
---|
[8258] | 719 | note = None |
---|
[7250] | 720 | |
---|
| 721 | @property |
---|
[7714] | 722 | def title(self): |
---|
[7819] | 723 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[7811] | 724 | return translate(_('Payment Data'), 'waeup.kofa', |
---|
[7714] | 725 | target_language=portal_language) |
---|
| 726 | |
---|
| 727 | @property |
---|
[7250] | 728 | def label(self): |
---|
[7819] | 729 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[8262] | 730 | return translate(_('Online Payment Slip'), |
---|
[7811] | 731 | 'waeup.kofa', target_language=portal_language) \ |
---|
[7714] | 732 | + ' %s' % self.context.p_id |
---|
[7250] | 733 | |
---|
[11754] | 734 | @property |
---|
| 735 | def payment_slip_download_warning(self): |
---|
| 736 | if self.context.__parent__.state != SUBMITTED: |
---|
| 737 | return _('Please submit the application form before ' |
---|
| 738 | 'trying to download payment slips.') |
---|
| 739 | return '' |
---|
| 740 | |
---|
[7250] | 741 | def render(self): |
---|
[11754] | 742 | if self.payment_slip_download_warning: |
---|
| 743 | self.flash(self.payment_slip_download_warning, type='danger') |
---|
[11599] | 744 | self.redirect(self.url(self.context)) |
---|
| 745 | return |
---|
[7259] | 746 | applicantview = ApplicantBaseDisplayFormPage(self.context.__parent__, |
---|
[7250] | 747 | self.request) |
---|
| 748 | students_utils = getUtility(IStudentsUtils) |
---|
[8262] | 749 | return students_utils.renderPDF(self,'payment_slip.pdf', |
---|
[8258] | 750 | self.context.__parent__, applicantview, note=self.note) |
---|
[7250] | 751 | |
---|
[10571] | 752 | class ExportPDFPageApplicationSlip(UtilityView, grok.View): |
---|
[6358] | 753 | """Deliver a PDF slip of the context. |
---|
| 754 | """ |
---|
| 755 | grok.context(IApplicant) |
---|
| 756 | grok.name('application_slip.pdf') |
---|
[7136] | 757 | grok.require('waeup.viewApplication') |
---|
[6358] | 758 | prefix = 'form' |
---|
| 759 | |
---|
[8666] | 760 | def update(self): |
---|
[9051] | 761 | if self.context.state in ('initialized', 'started', 'paid'): |
---|
[8666] | 762 | self.flash( |
---|
[11254] | 763 | _('Please pay and submit before trying to download ' |
---|
| 764 | 'the application slip.'), type='warning') |
---|
[8666] | 765 | return self.redirect(self.url(self.context)) |
---|
| 766 | return |
---|
| 767 | |
---|
[6358] | 768 | def render(self): |
---|
[12395] | 769 | try: |
---|
| 770 | pdfstream = getAdapter(self.context, IPDF, name='application_slip')( |
---|
| 771 | view=self) |
---|
| 772 | except IOError: |
---|
| 773 | self.flash( |
---|
| 774 | _('Your image file is corrupted. ' |
---|
| 775 | 'Please replace.'), type='danger') |
---|
| 776 | return self.redirect(self.url(self.context)) |
---|
[6358] | 777 | self.response.setHeader( |
---|
| 778 | 'Content-Type', 'application/pdf') |
---|
[7392] | 779 | return pdfstream |
---|
[6358] | 780 | |
---|
[7081] | 781 | def handle_img_upload(upload, context, view): |
---|
[7063] | 782 | """Handle upload of applicant image. |
---|
[7081] | 783 | |
---|
| 784 | Returns `True` in case of success or `False`. |
---|
| 785 | |
---|
| 786 | Please note that file pointer passed in (`upload`) most probably |
---|
| 787 | points to end of file when leaving this function. |
---|
[7063] | 788 | """ |
---|
[7081] | 789 | size = file_size(upload) |
---|
| 790 | if size > MAX_UPLOAD_SIZE: |
---|
[11254] | 791 | view.flash(_('Uploaded image is too big!'), type='danger') |
---|
[7081] | 792 | return False |
---|
[7247] | 793 | dummy, ext = os.path.splitext(upload.filename) |
---|
| 794 | ext.lower() |
---|
| 795 | if ext != '.jpg': |
---|
[11254] | 796 | view.flash(_('jpg file extension expected.'), type='danger') |
---|
[7247] | 797 | return False |
---|
[7081] | 798 | upload.seek(0) # file pointer moved when determining size |
---|
[7063] | 799 | store = getUtility(IExtFileStore) |
---|
| 800 | file_id = IFileStoreNameChooser(context).chooseName() |
---|
| 801 | store.createFile(file_id, upload) |
---|
[7081] | 802 | return True |
---|
[7063] | 803 | |
---|
[7819] | 804 | class ApplicantManageFormPage(KofaEditFormPage): |
---|
[6196] | 805 | """A full edit view for applicant data. |
---|
| 806 | """ |
---|
| 807 | grok.context(IApplicant) |
---|
[7200] | 808 | grok.name('manage') |
---|
[7136] | 809 | grok.require('waeup.manageApplication') |
---|
[7200] | 810 | grok.template('applicanteditpage') |
---|
[6322] | 811 | manage_applications = True |
---|
[6196] | 812 | pnav = 3 |
---|
[12664] | 813 | display_actions = [[_('Save'), _('Finally Submit')], |
---|
[7714] | 814 | [_('Add online payment ticket'),_('Remove selected tickets')]] |
---|
[6196] | 815 | |
---|
[8046] | 816 | @property |
---|
[10831] | 817 | def form_fields(self): |
---|
| 818 | if self.context.special: |
---|
[10845] | 819 | form_fields = grok.AutoFields(ISpecialApplicant) |
---|
| 820 | form_fields['applicant_id'].for_display = True |
---|
[10831] | 821 | else: |
---|
| 822 | form_fields = grok.AutoFields(IApplicant) |
---|
| 823 | form_fields['student_id'].for_display = True |
---|
| 824 | form_fields['applicant_id'].for_display = True |
---|
| 825 | return form_fields |
---|
| 826 | |
---|
| 827 | @property |
---|
[10534] | 828 | def target(self): |
---|
| 829 | return getattr(self.context.__parent__, 'prefix', None) |
---|
| 830 | |
---|
| 831 | @property |
---|
[8046] | 832 | def separators(self): |
---|
| 833 | return getUtility(IApplicantsUtils).SEPARATORS_DICT |
---|
| 834 | |
---|
[11733] | 835 | @property |
---|
| 836 | def custom_upload_requirements(self): |
---|
| 837 | return '' |
---|
| 838 | |
---|
[6196] | 839 | def update(self): |
---|
[7200] | 840 | super(ApplicantManageFormPage, self).update() |
---|
[6353] | 841 | self.wf_info = IWorkflowInfo(self.context) |
---|
[7081] | 842 | self.max_upload_size = string_from_bytes(MAX_UPLOAD_SIZE) |
---|
[10090] | 843 | self.upload_success = None |
---|
[6598] | 844 | upload = self.request.form.get('form.passport', None) |
---|
| 845 | if upload: |
---|
[11733] | 846 | if self.custom_upload_requirements: |
---|
| 847 | self.flash( |
---|
| 848 | self.custom_upload_requirements, |
---|
| 849 | type='danger') |
---|
| 850 | self.redirect(self.url(self.context)) |
---|
| 851 | return |
---|
[10090] | 852 | # We got a fresh upload, upload_success is |
---|
| 853 | # either True or False |
---|
| 854 | self.upload_success = handle_img_upload( |
---|
[7084] | 855 | upload, self.context, self) |
---|
[10090] | 856 | if self.upload_success: |
---|
[10095] | 857 | self.context.writeLogMessage(self, 'saved: passport') |
---|
[6196] | 858 | return |
---|
| 859 | |
---|
| 860 | @property |
---|
| 861 | def label(self): |
---|
| 862 | container_title = self.context.__parent__.title |
---|
[8096] | 863 | return _('${a} <br /> Application Form ${b}', mapping = { |
---|
[7714] | 864 | 'a':container_title, 'b':self.context.application_number}) |
---|
[6196] | 865 | |
---|
[6303] | 866 | def getTransitions(self): |
---|
[6351] | 867 | """Return a list of dicts of allowed transition ids and titles. |
---|
[6353] | 868 | |
---|
| 869 | Each list entry provides keys ``name`` and ``title`` for |
---|
| 870 | internal name and (human readable) title of a single |
---|
| 871 | transition. |
---|
[6349] | 872 | """ |
---|
[8434] | 873 | allowed_transitions = [t for t in self.wf_info.getManualTransitions() |
---|
[11482] | 874 | if not t[0] in ('pay', 'create')] |
---|
[7687] | 875 | return [dict(name='', title=_('No transition'))] +[ |
---|
[6355] | 876 | dict(name=x, title=y) for x, y in allowed_transitions] |
---|
[6303] | 877 | |
---|
[7714] | 878 | @action(_('Save'), style='primary') |
---|
[6196] | 879 | def save(self, **data): |
---|
[7240] | 880 | form = self.request.form |
---|
| 881 | password = form.get('password', None) |
---|
| 882 | password_ctl = form.get('control_password', None) |
---|
| 883 | if password: |
---|
| 884 | validator = getUtility(IPasswordValidator) |
---|
| 885 | errors = validator.validate_password(password, password_ctl) |
---|
| 886 | if errors: |
---|
[11254] | 887 | self.flash( ' '.join(errors), type='danger') |
---|
[7240] | 888 | return |
---|
[10090] | 889 | if self.upload_success is False: # False is not None! |
---|
| 890 | # Error during image upload. Ignore other values. |
---|
| 891 | return |
---|
[6475] | 892 | changed_fields = self.applyData(self.context, **data) |
---|
[7199] | 893 | # Turn list of lists into single list |
---|
| 894 | if changed_fields: |
---|
| 895 | changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) |
---|
[7240] | 896 | else: |
---|
| 897 | changed_fields = [] |
---|
| 898 | if password: |
---|
| 899 | # Now we know that the form has no errors and can set password ... |
---|
| 900 | IUserAccount(self.context).setPassword(password) |
---|
| 901 | changed_fields.append('password') |
---|
[7199] | 902 | fields_string = ' + '.join(changed_fields) |
---|
[7085] | 903 | trans_id = form.get('transition', None) |
---|
| 904 | if trans_id: |
---|
| 905 | self.wf_info.fireTransition(trans_id) |
---|
[7714] | 906 | self.flash(_('Form has been saved.')) |
---|
[6644] | 907 | if fields_string: |
---|
[12892] | 908 | self.context.writeLogMessage(self, 'saved: %s' % fields_string) |
---|
[6196] | 909 | return |
---|
| 910 | |
---|
[7250] | 911 | def unremovable(self, ticket): |
---|
[7330] | 912 | return False |
---|
[7250] | 913 | |
---|
| 914 | # This method is also used by the ApplicantEditFormPage |
---|
| 915 | def delPaymentTickets(self, **data): |
---|
| 916 | form = self.request.form |
---|
[9701] | 917 | if 'val_id' in form: |
---|
[7250] | 918 | child_id = form['val_id'] |
---|
| 919 | else: |
---|
[11254] | 920 | self.flash(_('No payment selected.'), type='warning') |
---|
[7250] | 921 | self.redirect(self.url(self.context)) |
---|
| 922 | return |
---|
| 923 | if not isinstance(child_id, list): |
---|
| 924 | child_id = [child_id] |
---|
| 925 | deleted = [] |
---|
| 926 | for id in child_id: |
---|
| 927 | # Applicants are not allowed to remove used payment tickets |
---|
| 928 | if not self.unremovable(self.context[id]): |
---|
| 929 | try: |
---|
| 930 | del self.context[id] |
---|
| 931 | deleted.append(id) |
---|
| 932 | except: |
---|
[7714] | 933 | self.flash(_('Could not delete:') + ' %s: %s: %s' % ( |
---|
[11254] | 934 | id, sys.exc_info()[0], sys.exc_info()[1]), type='danger') |
---|
[7250] | 935 | if len(deleted): |
---|
[7741] | 936 | self.flash(_('Successfully removed: ${a}', |
---|
[7738] | 937 | mapping = {'a':', '.join(deleted)})) |
---|
[8742] | 938 | self.context.writeLogMessage( |
---|
| 939 | self, 'removed: % s' % ', '.join(deleted)) |
---|
[7250] | 940 | return |
---|
| 941 | |
---|
[7252] | 942 | # We explicitely want the forms to be validated before payment tickets |
---|
| 943 | # can be created. If no validation is requested, use |
---|
[7459] | 944 | # 'validator=NullValidator' in the action directive |
---|
[11578] | 945 | @action(_('Add online payment ticket'), style='primary') |
---|
[7250] | 946 | def addPaymentTicket(self, **data): |
---|
| 947 | self.redirect(self.url(self.context, '@@addafp')) |
---|
[7252] | 948 | return |
---|
[7250] | 949 | |
---|
[7714] | 950 | @jsaction(_('Remove selected tickets')) |
---|
[7250] | 951 | def removePaymentTickets(self, **data): |
---|
| 952 | self.delPaymentTickets(**data) |
---|
| 953 | self.redirect(self.url(self.context) + '/@@manage') |
---|
| 954 | return |
---|
| 955 | |
---|
[10094] | 956 | # Not used in base package |
---|
| 957 | def file_exists(self, attr): |
---|
| 958 | file = getUtility(IExtFileStore).getFileByContext( |
---|
| 959 | self.context, attr=attr) |
---|
| 960 | if file: |
---|
| 961 | return True |
---|
| 962 | else: |
---|
| 963 | return False |
---|
| 964 | |
---|
[7200] | 965 | class ApplicantEditFormPage(ApplicantManageFormPage): |
---|
[5982] | 966 | """An applicant-centered edit view for applicant data. |
---|
| 967 | """ |
---|
[6196] | 968 | grok.context(IApplicantEdit) |
---|
[5273] | 969 | grok.name('edit') |
---|
[6198] | 970 | grok.require('waeup.handleApplication') |
---|
[7200] | 971 | grok.template('applicanteditpage') |
---|
[6322] | 972 | manage_applications = False |
---|
[10358] | 973 | submit_state = PAID |
---|
[5484] | 974 | |
---|
[7250] | 975 | @property |
---|
[10831] | 976 | def form_fields(self): |
---|
| 977 | if self.context.special: |
---|
[11657] | 978 | form_fields = grok.AutoFields(ISpecialApplicant).omit( |
---|
| 979 | 'locked', 'suspended') |
---|
[10845] | 980 | form_fields['applicant_id'].for_display = True |
---|
[10831] | 981 | else: |
---|
| 982 | form_fields = grok.AutoFields(IApplicantEdit).omit( |
---|
| 983 | 'locked', 'course_admitted', 'student_id', |
---|
[10845] | 984 | 'suspended' |
---|
[10831] | 985 | ) |
---|
| 986 | form_fields['applicant_id'].for_display = True |
---|
| 987 | form_fields['reg_number'].for_display = True |
---|
| 988 | return form_fields |
---|
| 989 | |
---|
| 990 | @property |
---|
[7250] | 991 | def display_actions(self): |
---|
[8286] | 992 | state = IWorkflowState(self.context).getState() |
---|
[13100] | 993 | # If the form is unlocked, applicants are allowed to save the form |
---|
| 994 | # and remove unused tickets. |
---|
| 995 | actions = [[_('Save')], [_('Remove selected tickets')]] |
---|
| 996 | # Only in state started they can also add tickets. |
---|
[10358] | 997 | if state == STARTED: |
---|
[7714] | 998 | actions = [[_('Save')], |
---|
| 999 | [_('Add online payment ticket'),_('Remove selected tickets')]] |
---|
[13100] | 1000 | # In state paid, they can submit the data and further add tickets |
---|
| 1001 | # if the application is special. |
---|
[11599] | 1002 | elif self.context.special and state == PAID: |
---|
[12664] | 1003 | actions = [[_('Save'), _('Finally Submit')], |
---|
[11599] | 1004 | [_('Add online payment ticket'),_('Remove selected tickets')]] |
---|
[8286] | 1005 | elif state == PAID: |
---|
[12664] | 1006 | actions = [[_('Save'), _('Finally Submit')], |
---|
[7714] | 1007 | [_('Remove selected tickets')]] |
---|
[7250] | 1008 | return actions |
---|
| 1009 | |
---|
[7330] | 1010 | def unremovable(self, ticket): |
---|
[13100] | 1011 | return ticket.r_code |
---|
[7330] | 1012 | |
---|
[7145] | 1013 | def emit_lock_message(self): |
---|
[11254] | 1014 | self.flash(_('The requested form is locked (read-only).'), |
---|
| 1015 | type='warning') |
---|
[5941] | 1016 | self.redirect(self.url(self.context)) |
---|
| 1017 | return |
---|
[6078] | 1018 | |
---|
[5686] | 1019 | def update(self): |
---|
[8665] | 1020 | if self.context.locked or ( |
---|
| 1021 | self.context.__parent__.expired and |
---|
| 1022 | self.context.__parent__.strict_deadline): |
---|
[7145] | 1023 | self.emit_lock_message() |
---|
[5941] | 1024 | return |
---|
[7200] | 1025 | super(ApplicantEditFormPage, self).update() |
---|
[5686] | 1026 | return |
---|
[5952] | 1027 | |
---|
[6196] | 1028 | def dataNotComplete(self): |
---|
[7252] | 1029 | store = getUtility(IExtFileStore) |
---|
| 1030 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
[7714] | 1031 | return _('No passport picture uploaded.') |
---|
[6322] | 1032 | if not self.request.form.get('confirm_passport', False): |
---|
[7714] | 1033 | return _('Passport picture confirmation box not ticked.') |
---|
[6196] | 1034 | return False |
---|
[5952] | 1035 | |
---|
[7252] | 1036 | # We explicitely want the forms to be validated before payment tickets |
---|
| 1037 | # can be created. If no validation is requested, use |
---|
[7459] | 1038 | # 'validator=NullValidator' in the action directive |
---|
[11578] | 1039 | @action(_('Add online payment ticket'), style='primary') |
---|
[7250] | 1040 | def addPaymentTicket(self, **data): |
---|
| 1041 | self.redirect(self.url(self.context, '@@addafp')) |
---|
[7252] | 1042 | return |
---|
[7250] | 1043 | |
---|
[7714] | 1044 | @jsaction(_('Remove selected tickets')) |
---|
[7250] | 1045 | def removePaymentTickets(self, **data): |
---|
| 1046 | self.delPaymentTickets(**data) |
---|
| 1047 | self.redirect(self.url(self.context) + '/@@edit') |
---|
| 1048 | return |
---|
| 1049 | |
---|
[7996] | 1050 | @action(_('Save'), style='primary') |
---|
[5273] | 1051 | def save(self, **data): |
---|
[10090] | 1052 | if self.upload_success is False: # False is not None! |
---|
| 1053 | # Error during image upload. Ignore other values. |
---|
| 1054 | return |
---|
[10219] | 1055 | if data.get('course1', 1) == data.get('course2', 2): |
---|
[11254] | 1056 | self.flash(_('1st and 2nd choice must be different.'), |
---|
| 1057 | type='warning') |
---|
[10210] | 1058 | return |
---|
[5273] | 1059 | self.applyData(self.context, **data) |
---|
[10210] | 1060 | self.flash(_('Form has been saved.')) |
---|
[5273] | 1061 | return |
---|
| 1062 | |
---|
[12664] | 1063 | @action(_('Finally Submit'), warning=WARNING) |
---|
[5484] | 1064 | def finalsubmit(self, **data): |
---|
[10090] | 1065 | if self.upload_success is False: # False is not None! |
---|
[7084] | 1066 | return # error during image upload. Ignore other values |
---|
[6196] | 1067 | if self.dataNotComplete(): |
---|
[11254] | 1068 | self.flash(self.dataNotComplete(), type='danger') |
---|
[5941] | 1069 | return |
---|
[7252] | 1070 | self.applyData(self.context, **data) |
---|
[8286] | 1071 | state = IWorkflowState(self.context).getState() |
---|
[6322] | 1072 | # This shouldn't happen, but the application officer |
---|
| 1073 | # might have forgotten to lock the form after changing the state |
---|
[10358] | 1074 | if state != self.submit_state: |
---|
[11254] | 1075 | self.flash(_('The form cannot be submitted. Wrong state!'), |
---|
| 1076 | type='danger') |
---|
[6303] | 1077 | return |
---|
| 1078 | IWorkflowInfo(self.context).fireTransition('submit') |
---|
[8589] | 1079 | # application_date is used in export files for sorting. |
---|
| 1080 | # We can thus store utc. |
---|
[8194] | 1081 | self.context.application_date = datetime.utcnow() |
---|
[7714] | 1082 | self.flash(_('Form has been submitted.')) |
---|
[6196] | 1083 | self.redirect(self.url(self.context)) |
---|
[5273] | 1084 | return |
---|
[5941] | 1085 | |
---|
[7063] | 1086 | class PassportImage(grok.View): |
---|
| 1087 | """Renders the passport image for applicants. |
---|
| 1088 | """ |
---|
| 1089 | grok.name('passport.jpg') |
---|
| 1090 | grok.context(IApplicant) |
---|
[7113] | 1091 | grok.require('waeup.viewApplication') |
---|
[7063] | 1092 | |
---|
| 1093 | def render(self): |
---|
| 1094 | # A filename chooser turns a context into a filename suitable |
---|
| 1095 | # for file storage. |
---|
| 1096 | image = getUtility(IExtFileStore).getFileByContext(self.context) |
---|
| 1097 | self.response.setHeader( |
---|
| 1098 | 'Content-Type', 'image/jpeg') |
---|
| 1099 | if image is None: |
---|
| 1100 | # show placeholder image |
---|
[7089] | 1101 | return open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb').read() |
---|
[7063] | 1102 | return image |
---|
[7363] | 1103 | |
---|
[7819] | 1104 | class ApplicantRegistrationPage(KofaAddFormPage): |
---|
[7363] | 1105 | """Captcha'd registration page for applicants. |
---|
| 1106 | """ |
---|
| 1107 | grok.context(IApplicantsContainer) |
---|
| 1108 | grok.name('register') |
---|
[7373] | 1109 | grok.require('waeup.Anonymous') |
---|
[7363] | 1110 | grok.template('applicantregister') |
---|
| 1111 | |
---|
[7368] | 1112 | @property |
---|
[8033] | 1113 | def form_fields(self): |
---|
| 1114 | form_fields = None |
---|
[8128] | 1115 | if self.context.mode == 'update': |
---|
| 1116 | form_fields = grok.AutoFields(IApplicantRegisterUpdate).select( |
---|
[11738] | 1117 | 'lastname','reg_number','email') |
---|
[8128] | 1118 | else: #if self.context.mode == 'create': |
---|
[8033] | 1119 | form_fields = grok.AutoFields(IApplicantEdit).select( |
---|
| 1120 | 'firstname', 'middlename', 'lastname', 'email', 'phone') |
---|
| 1121 | return form_fields |
---|
| 1122 | |
---|
| 1123 | @property |
---|
[7368] | 1124 | def label(self): |
---|
[8078] | 1125 | return _('Apply for ${a}', |
---|
[7714] | 1126 | mapping = {'a':self.context.title}) |
---|
[7368] | 1127 | |
---|
[7363] | 1128 | def update(self): |
---|
[8665] | 1129 | if self.context.expired: |
---|
[11254] | 1130 | self.flash(_('Outside application period.'), type='warning') |
---|
[7368] | 1131 | self.redirect(self.url(self.context)) |
---|
| 1132 | return |
---|
| 1133 | # Handle captcha |
---|
[7363] | 1134 | self.captcha = getUtility(ICaptchaManager).getCaptcha() |
---|
| 1135 | self.captcha_result = self.captcha.verify(self.request) |
---|
| 1136 | self.captcha_code = self.captcha.display(self.captcha_result.error_code) |
---|
| 1137 | return |
---|
| 1138 | |
---|
[8629] | 1139 | def _redirect(self, email, password, applicant_id): |
---|
| 1140 | # Forward only email to landing page in base package. |
---|
| 1141 | self.redirect(self.url(self.context, 'registration_complete', |
---|
| 1142 | data = dict(email=email))) |
---|
| 1143 | return |
---|
| 1144 | |
---|
[9178] | 1145 | @action(_('Send login credentials to email address'), style='primary') |
---|
[7363] | 1146 | def register(self, **data): |
---|
| 1147 | if not self.captcha_result.is_valid: |
---|
[8037] | 1148 | # Captcha will display error messages automatically. |
---|
[7363] | 1149 | # No need to flash something. |
---|
| 1150 | return |
---|
[8033] | 1151 | if self.context.mode == 'create': |
---|
| 1152 | # Add applicant |
---|
| 1153 | applicant = createObject(u'waeup.Applicant') |
---|
| 1154 | self.applyData(applicant, **data) |
---|
| 1155 | self.context.addApplicant(applicant) |
---|
[8042] | 1156 | applicant.reg_number = applicant.applicant_id |
---|
| 1157 | notify(grok.ObjectModifiedEvent(applicant)) |
---|
[8033] | 1158 | elif self.context.mode == 'update': |
---|
| 1159 | # Update applicant |
---|
[8037] | 1160 | reg_number = data.get('reg_number','') |
---|
[11738] | 1161 | lastname = data.get('lastname','') |
---|
[8033] | 1162 | cat = getUtility(ICatalog, name='applicants_catalog') |
---|
| 1163 | results = list( |
---|
| 1164 | cat.searchResults(reg_number=(reg_number, reg_number))) |
---|
| 1165 | if results: |
---|
| 1166 | applicant = results[0] |
---|
[11738] | 1167 | if getattr(applicant,'lastname',None) is None: |
---|
[11254] | 1168 | self.flash(_('An error occurred.'), type='danger') |
---|
[8037] | 1169 | return |
---|
[11738] | 1170 | elif applicant.lastname.lower() != lastname.lower(): |
---|
[8042] | 1171 | # Don't tell the truth here. Anonymous must not |
---|
[11738] | 1172 | # know that a record was found and only the lastname |
---|
[8042] | 1173 | # verification failed. |
---|
[13099] | 1174 | self.flash( |
---|
| 1175 | _('No application record found.'), type='warning') |
---|
[8037] | 1176 | return |
---|
[8627] | 1177 | elif applicant.password is not None and \ |
---|
| 1178 | applicant.state != INITIALIZED: |
---|
| 1179 | self.flash(_('Your password has already been set and used. ' |
---|
[11254] | 1180 | 'Please proceed to the login page.'), |
---|
| 1181 | type='warning') |
---|
[8042] | 1182 | return |
---|
| 1183 | # Store email address but nothing else. |
---|
[8033] | 1184 | applicant.email = data['email'] |
---|
[8042] | 1185 | notify(grok.ObjectModifiedEvent(applicant)) |
---|
[8033] | 1186 | else: |
---|
[8042] | 1187 | # No record found, this is the truth. |
---|
[11254] | 1188 | self.flash(_('No application record found.'), type='warning') |
---|
[8033] | 1189 | return |
---|
| 1190 | else: |
---|
[8042] | 1191 | # Does not happen but anyway ... |
---|
[8033] | 1192 | return |
---|
[7819] | 1193 | kofa_utils = getUtility(IKofaUtils) |
---|
[7811] | 1194 | password = kofa_utils.genPassword() |
---|
[7380] | 1195 | IUserAccount(applicant).setPassword(password) |
---|
[7365] | 1196 | # Send email with credentials |
---|
[7399] | 1197 | login_url = self.url(grok.getSite(), 'login') |
---|
[8853] | 1198 | url_info = u'Login: %s' % login_url |
---|
[7714] | 1199 | msg = _('You have successfully been registered for the') |
---|
[7811] | 1200 | if kofa_utils.sendCredentials(IUserAccount(applicant), |
---|
[8853] | 1201 | password, url_info, msg): |
---|
[8629] | 1202 | email_sent = applicant.email |
---|
[7380] | 1203 | else: |
---|
[8629] | 1204 | email_sent = None |
---|
| 1205 | self._redirect(email=email_sent, password=password, |
---|
| 1206 | applicant_id=applicant.applicant_id) |
---|
[7380] | 1207 | return |
---|
| 1208 | |
---|
[7819] | 1209 | class ApplicantRegistrationEmailSent(KofaPage): |
---|
[7380] | 1210 | """Landing page after successful registration. |
---|
[8629] | 1211 | |
---|
[7380] | 1212 | """ |
---|
| 1213 | grok.name('registration_complete') |
---|
| 1214 | grok.require('waeup.Public') |
---|
| 1215 | grok.template('applicantregemailsent') |
---|
[7714] | 1216 | label = _('Your registration was successful.') |
---|
[7380] | 1217 | |
---|
[8629] | 1218 | def update(self, email=None, applicant_id=None, password=None): |
---|
[7380] | 1219 | self.email = email |
---|
[8629] | 1220 | self.password = password |
---|
| 1221 | self.applicant_id = applicant_id |
---|
[7380] | 1222 | return |
---|
[10655] | 1223 | |
---|
| 1224 | class ExportJobContainerOverview(KofaPage): |
---|
| 1225 | """Page that lists active applicant data export jobs and provides links |
---|
| 1226 | to discard or download CSV files. |
---|
| 1227 | |
---|
| 1228 | """ |
---|
| 1229 | grok.context(VirtualApplicantsExportJobContainer) |
---|
| 1230 | grok.require('waeup.manageApplication') |
---|
| 1231 | grok.name('index.html') |
---|
| 1232 | grok.template('exportjobsindex') |
---|
[11254] | 1233 | label = _('Data Exports') |
---|
[10655] | 1234 | pnav = 3 |
---|
| 1235 | |
---|
| 1236 | def update(self, CREATE=None, DISCARD=None, job_id=None): |
---|
| 1237 | if CREATE: |
---|
| 1238 | self.redirect(self.url('@@start_export')) |
---|
| 1239 | return |
---|
| 1240 | if DISCARD and job_id: |
---|
| 1241 | entry = self.context.entry_from_job_id(job_id) |
---|
| 1242 | self.context.delete_export_entry(entry) |
---|
| 1243 | ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') |
---|
| 1244 | self.context.logger.info( |
---|
| 1245 | '%s - discarded: job_id=%s' % (ob_class, job_id)) |
---|
| 1246 | self.flash(_('Discarded export') + ' %s' % job_id) |
---|
| 1247 | self.entries = doll_up(self, user=self.request.principal.id) |
---|
| 1248 | return |
---|
| 1249 | |
---|
| 1250 | class ExportJobContainerJobStart(KofaPage): |
---|
| 1251 | """Page that starts an applicants export job. |
---|
| 1252 | |
---|
| 1253 | """ |
---|
| 1254 | grok.context(VirtualApplicantsExportJobContainer) |
---|
| 1255 | grok.require('waeup.manageApplication') |
---|
| 1256 | grok.name('start_export') |
---|
| 1257 | |
---|
| 1258 | def update(self): |
---|
[13152] | 1259 | utils = queryUtility(IKofaUtils) |
---|
| 1260 | if not utils.expensive_actions_allowed(): |
---|
| 1261 | self.flash(_( |
---|
| 1262 | "Currently, exporters cannot be started due to high " |
---|
| 1263 | "system load. Please try again later."), type='danger') |
---|
| 1264 | self.entries = doll_up(self, user=None) |
---|
| 1265 | return |
---|
[10655] | 1266 | exporter = 'applicants' |
---|
| 1267 | container_code = self.context.__parent__.code |
---|
| 1268 | job_id = self.context.start_export_job(exporter, |
---|
| 1269 | self.request.principal.id, |
---|
| 1270 | container=container_code) |
---|
| 1271 | |
---|
| 1272 | ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') |
---|
| 1273 | self.context.logger.info( |
---|
| 1274 | '%s - exported: %s (%s), job_id=%s' |
---|
| 1275 | % (ob_class, exporter, container_code, job_id)) |
---|
| 1276 | self.flash(_('Export started.')) |
---|
| 1277 | self.redirect(self.url(self.context)) |
---|
| 1278 | return |
---|
| 1279 | |
---|
| 1280 | def render(self): |
---|
| 1281 | return |
---|
| 1282 | |
---|
| 1283 | class ExportJobContainerDownload(ExportCSVView): |
---|
| 1284 | """Page that downloads a students export csv file. |
---|
| 1285 | |
---|
| 1286 | """ |
---|
| 1287 | grok.context(VirtualApplicantsExportJobContainer) |
---|
[11253] | 1288 | grok.require('waeup.manageApplication') |
---|