source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py @ 5779

Last change on this file since 5779 was 5777, checked in by uli, 14 years ago

Remove JAMB-based login (it is handled in jambtables).

File size: 5.0 KB
Line 
1##
2## browser.py
3## Login : <uli@pu.smp.net>
4## Started on  Sun Jun 27 11:03:10 2010 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2010 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22"""UI components for JAMB tables.
23"""
24import grok
25
26from zope.formlib.widgets import FileWidget
27from waeup.sirp.browser import (
28    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage,
29    WAeUPDisplayFormPage, NullValidator)
30from waeup.sirp.browser.pages import LoginPage
31from waeup.sirp.interfaces import IWAeUPObject
32from waeup.sirp.applicants.jambtables.util import get_applicant_data
33from waeup.sirp.applicants.interfaces import (
34    IApplicant, IApplicantPrincipal, IApplicantPDEEditData)
35from waeup.sirp.widgets.passportwidget import (
36    PassportWidget, PassportDisplayWidget
37    )
38#from zope.formlib.objectwidget import ObjectWidget
39from zope.formlib.sequencewidget import ListSequenceWidget, SequenceDisplayWidget
40from zope.formlib.widget import CustomWidgetFactory
41from waeup.sirp.applicants import ResultEntry
42from waeup.sirp.widgets.objectwidget import (
43    WAeUPObjectWidget, WAeUPObjectDisplayWidget)
44from waeup.sirp.widgets.multilistwidget import (
45    MultiListWidget, MultiListDisplayWidget)
46from waeup.sirp.image.browser.widget import (
47    ThumbnailWidget, EncodingImageFileWidget,
48    )
49
50results_widget = CustomWidgetFactory(
51    WAeUPObjectWidget, ResultEntry)
52
53results_display_widget = CustomWidgetFactory(
54    WAeUPObjectDisplayWidget, ResultEntry)
55
56#list_results_widget = CustomWidgetFactory(
57#    ListSequenceWidget, subwidget=results_widget)
58
59list_results_widget = CustomWidgetFactory(
60    MultiListWidget, subwidget=results_widget)
61
62list_results_display_widget = CustomWidgetFactory(
63    MultiListDisplayWidget, subwidget=results_display_widget)
64
65#class ApplicationsPage(WAeUPPage):
66#    grok.context(IApplicantContainer)
67#    grok.name('index')
68#    title = 'Applications'
69#    pnav = 1
70#   
71#    def getApplications(self):
72#        """Get a list of all stored applications.
73#        """
74#        for key, val in self.context.items():
75#            url = self.url(val)
76#            yield(dict(url=url, name=key))
77
78#class AddApplicant(WAeUPAddFormPage):
79#    grok.context(IApplicantContainer)
80#    grok.name('add')
81#    form_fields = grok.AutoFields(IApplicant)
82#    form_fields['fst_sit_results'].custom_widget = list_results_widget
83#    form_fields['passport'].custom_widget = EncodingImageFileWidget
84#    label = 'Add Applicant'
85#    title = 'Add Applicant'
86#    pnav = 1
87#
88#    @grok.action('Add applicant')
89#    def addApplicant(self, **data):
90#        from waeup.sirp.jambtables.applicants import Applicant
91#        applicant = Applicant()
92#        self.applyData(applicant, **data)
93#        # XXX: temporarily disabled.
94#        #self.context[applicant.reg_no] = applicant
95#        try:
96#            self.context[applicant.access_code] = applicant
97#        except KeyError:
98#            self.flash('The given access code is already in use!')
99#            return
100#        self.redirect(self.url(self.context))
101
102class DisplayApplicant(WAeUPDisplayFormPage):
103    grok.context(IApplicant)
104    grok.name('index')
105    form_fields = grok.AutoFields(IApplicant)
106    form_fields['fst_sit_results'].custom_widget = list_results_display_widget
107    #form_fields['passport'].custom_widget = PassportDisplayWidget
108    form_fields['passport'].custom_widget = ThumbnailWidget
109    label = 'Applicant'
110    title = 'Applicant'
111    pnav = 1
112
113class EditApplicant(WAeUPEditFormPage):
114    grok.context(IApplicant)
115    grok.name('edit')
116    form_fields = grok.AutoFields(IApplicantPDEEditData)
117    #form_fields['passport'].custom_widget = FileWidget
118    #form_fields['passport'].custom_widget = PassportWidget
119    form_fields['passport'].custom_widget = EncodingImageFileWidget
120    grok.template('form_edit_pde')
121
122    def update(self):
123        super(EditApplicant, self).update()
124        print self.request.form
125        return
126   
127    @property
128    def label(self):
129        # XXX: Use current/upcoming session
130        return 'Apply for Post UDE Screening Test (2009/2010)'
131    title = 'Edit Application'
132    pnav = 1
133
134    @grok.action('Save')
135    def save(self, **data):
136        self.applyData(self.context, **data)
137        self.context._p_changed = True
138        return
139
140    @grok.action('Final Submit')
141    def finalsubmit(self, **data):
142        self.applyData(self.context, **data)
143        self.context._p_changed = True
144        # XXX: Lock the form for editing...
145        return
Note: See TracBrowser for help on using the repository browser.