1 | ## $Id: interfaces.py 14197 2016-09-28 07:04:12Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2014 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 | |
---|
19 | import re |
---|
20 | from zope import schema |
---|
21 | from waeup.ikoba.interfaces import IIkobaObject |
---|
22 | from waeup.ikoba.schema import FormattedDate, PhoneNumber |
---|
23 | from waeup.ikoba.customers.interfaces import ( |
---|
24 | ICustomer, ICustomerDocument, ICustomerPDFDocument, IContract) |
---|
25 | from waeup.ikoba.customers.vocabularies import ( |
---|
26 | ConCatProductSource, CustomerDocumentSource, nats_vocab) |
---|
27 | from waeup.ikoba.products.productoptions import ProductOptionField |
---|
28 | from ikobacustom.uniben.interfaces import MessageFactory as _ |
---|
29 | |
---|
30 | class NotUnibenEmailAddress(schema.ValidationError): |
---|
31 | __doc__ = u"Invalid Uniben email address" |
---|
32 | |
---|
33 | check_email = re.compile( |
---|
34 | r"^[^@\s,]+@[^@\.\s,]+(\.[^@\.\s,]+)*$").match |
---|
35 | |
---|
36 | def validate_uniben_email(value): |
---|
37 | if not check_email(value): |
---|
38 | raise NotUnibenEmailAddress(value) |
---|
39 | if not value.endswith('uniben.edu'): |
---|
40 | raise NotUnibenEmailAddress(value) |
---|
41 | return True |
---|
42 | |
---|
43 | class IUnibenCustomer(ICustomer): |
---|
44 | """Representation of a customer. |
---|
45 | |
---|
46 | """ |
---|
47 | |
---|
48 | # Customer document interfaces |
---|
49 | |
---|
50 | |
---|
51 | class IUnibenCustomerJPGDocument(ICustomerDocument): |
---|
52 | """A customer document. |
---|
53 | |
---|
54 | """ |
---|
55 | |
---|
56 | class IUnibenCustomerPDFDocument(ICustomerPDFDocument): |
---|
57 | """A customer pdf document. |
---|
58 | |
---|
59 | """ |
---|
60 | |
---|
61 | # Customer contract interfaces |
---|
62 | |
---|
63 | class IUnibenContract(IContract): |
---|
64 | """A customer contract with document attached. |
---|
65 | |
---|
66 | """ |
---|
67 | |
---|
68 | nominator_title_rank = schema.TextLine( |
---|
69 | title = _(u'Title/Rank'), |
---|
70 | required = False, |
---|
71 | ) |
---|
72 | |
---|
73 | nominator_nationality = schema.Choice( |
---|
74 | vocabulary = nats_vocab, |
---|
75 | title = _(u'Current Nationality'), |
---|
76 | required = False, |
---|
77 | ) |
---|
78 | |
---|
79 | nominator_address = schema.Text( |
---|
80 | title = _(u'Affiliation/Address'), |
---|
81 | required = False, |
---|
82 | ) |
---|
83 | |
---|
84 | nominee_fullname = schema.TextLine( |
---|
85 | title = _(u'Name'), |
---|
86 | description = u'Surname last and in capital letters', |
---|
87 | required = False, |
---|
88 | ) |
---|
89 | |
---|
90 | nominee_title_rank = schema.TextLine( |
---|
91 | title = _(u'Title/Rank'), |
---|
92 | required = False, |
---|
93 | ) |
---|
94 | |
---|
95 | nominee_department = schema.TextLine( |
---|
96 | title = _(u'Department/Faculty/Institute'), |
---|
97 | required = False, |
---|
98 | ) |
---|
99 | |
---|
100 | nominee_date_of_birth = FormattedDate( |
---|
101 | title = _(u'Date of Birth'), |
---|
102 | required = False, |
---|
103 | show_year = True, |
---|
104 | ) |
---|
105 | |
---|
106 | nominee_nationality = schema.Choice( |
---|
107 | vocabulary = nats_vocab, |
---|
108 | title = _(u'Current Nationality'), |
---|
109 | required = False, |
---|
110 | ) |
---|
111 | |
---|
112 | nominee_email = schema.ASCIILine( |
---|
113 | title = _(u'Uniben Email Address'), |
---|
114 | required = True, |
---|
115 | constraint=validate_uniben_email, |
---|
116 | ) |
---|
117 | |
---|
118 | nominee_phone = PhoneNumber( |
---|
119 | title = _(u'Phone'), |
---|
120 | description = u'', |
---|
121 | required = False, |
---|
122 | ) |
---|
123 | |
---|
124 | app_dates = schema.Text( |
---|
125 | title = _(u'Date of Appointment as Uniben staff'), |
---|
126 | description = u'State periods nominee had a break in service from ' |
---|
127 | 'UNIBEN service (including leave of absence), ' |
---|
128 | 'but excluding training/study/sabbatical leave', |
---|
129 | required = False, |
---|
130 | ) |
---|
131 | |
---|
132 | bib_cit = schema.Text( |
---|
133 | title = _(u'Biographical Citation'), |
---|
134 | description = u'Suggested biographical citation of ' |
---|
135 | 'nominee (max. 200 words) in the event that the ' |
---|
136 | 'nominee is selected for the award.', |
---|
137 | required = False, |
---|
138 | ) |
---|
139 | |
---|
140 | sup_stat = schema.Text( |
---|
141 | title = _(u'Supporting Statement'), |
---|
142 | description = u'Supporting statement (max. 200 words) summarizing ' |
---|
143 | 'the research and innovative achievement of the ' |
---|
144 | 'candidate. It should preferably focus on one major ' |
---|
145 | 'achievement/innovation/accomplishment.', |
---|
146 | required = False, |
---|
147 | ) |
---|
148 | |
---|
149 | nar_wu = schema.Text( |
---|
150 | title = _(u'Narrative Write-Up'), |
---|
151 | description = u'A narrative write-up (max. 1,000 words) of the ' |
---|
152 | 'candidate highlighting his/her scientific/creative ' |
---|
153 | 'achievement and/or innovation; restrict to one major ' |
---|
154 | 'innovation/achievement/accomplishment. ' |
---|
155 | 'The national/international impact of the ' |
---|
156 | 'achievement/innovation should be emphasized.', |
---|
157 | required = False, |
---|
158 | ) |
---|
159 | |
---|
160 | item_stat = schema.Text( |
---|
161 | title = _(u'Itemized Statement'), |
---|
162 | description = u'Itemized statement of research leadership and ' |
---|
163 | 'collaboration (max. 100 words)', |
---|
164 | required = False, |
---|
165 | ) |
---|
166 | |
---|
167 | sign_pub = schema.Text( |
---|
168 | title = _(u'Significant Publications'), |
---|
169 | description = u'A list of his/her most significant publications ' |
---|
170 | '(max. 10) pertaining to the achievement/innovation ' |
---|
171 | 'along with each publication\'s H-index', |
---|
172 | required = False, |
---|
173 | ) |
---|
174 | |
---|
175 | prev_aw = schema.Text( |
---|
176 | title = _(u'Previous Awards'), |
---|
177 | description = u'List of previous awards, honours and recognition ' |
---|
178 | '(max. 10) received by nominee, including awarding ' |
---|
179 | 'body, purpose of award, date of award, and nature ' |
---|
180 | 'of award (cash, certificate, plaque, etc)', |
---|
181 | required = False, |
---|
182 | ) |
---|
183 | |
---|
184 | lead_rol = schema.Text( |
---|
185 | title = _(u'Leadership Roles'), |
---|
186 | description = u'List of leadership roles in academic/professional ' |
---|
187 | 'societies/organizations (max. no. of 3)', |
---|
188 | required = False, |
---|
189 | ) |
---|
190 | |
---|
191 | h_index = schema.Text( |
---|
192 | title = _(u'State H-Index'), |
---|
193 | description = u'State the full H-index of author, i.e. nominee', |
---|
194 | required = False, |
---|
195 | ) |
---|
196 | |
---|
197 | doc1 = schema.Choice( |
---|
198 | title = _(u'Curriculum Vitae'), |
---|
199 | source = CustomerDocumentSource(), |
---|
200 | description = u'A curriculum vitae including a full list of scholarly ' |
---|
201 | 'publications', |
---|
202 | required = False, |
---|
203 | ) |
---|
204 | |
---|
205 | doc2 = schema.Choice( |
---|
206 | title = _(u'Reference Letters'), |
---|
207 | source = CustomerDocumentSource(), |
---|
208 | description = u'Reference letters from three referees ' |
---|
209 | 'added together in a pdf document', |
---|
210 | required = False, |
---|
211 | ) |
---|
212 | |
---|
213 | doc3 = schema.Choice( |
---|
214 | title = _(u'Photo or Illustration 1'), |
---|
215 | source = CustomerDocumentSource(), |
---|
216 | description = u'(optional)', |
---|
217 | required = False, |
---|
218 | ) |
---|
219 | |
---|
220 | |
---|
221 | doc4 = schema.Choice( |
---|
222 | title = _(u'Photo or Illustration 2'), |
---|
223 | source = CustomerDocumentSource(), |
---|
224 | description = u'(optional)', |
---|
225 | required = False, |
---|
226 | ) |
---|
227 | |
---|
228 | doc5 = schema.Choice( |
---|
229 | title = _(u'Photo or Illustration 3'), |
---|
230 | source = CustomerDocumentSource(), |
---|
231 | description = u'(optional)', |
---|
232 | required = False, |
---|
233 | ) |
---|
234 | class IRIAAContract(IUnibenContract): |
---|
235 | """A Retention of Name contract. |
---|
236 | |
---|
237 | """ |
---|
238 | |
---|
239 | class IRIAAContractOfficialUse(IIkobaObject): |
---|
240 | """Interface for editing RIAA official use data. |
---|
241 | |
---|
242 | """ |
---|
243 | |
---|
244 | comment = schema.Text( |
---|
245 | title= _('Reason for rejection'), |
---|
246 | required = False, |
---|
247 | ) |
---|
248 | |
---|
249 | |
---|
250 | class IRIAAContractProcess(IRIAAContract, IRIAAContractOfficialUse): |
---|
251 | """Interface for processing RIAA data. |
---|
252 | """ |
---|
253 | |
---|
254 | product_options = schema.List( |
---|
255 | title = _(u'Options/Fees'), |
---|
256 | value_type = ProductOptionField(), |
---|
257 | required = False, |
---|
258 | readonly = False, |
---|
259 | defaultFactory=list, |
---|
260 | ) |
---|
261 | |
---|
262 | class IRIAAContractEdit(IRIAAContract): |
---|
263 | """Interface for editing RIAA data by customers. |
---|
264 | |
---|
265 | """ |
---|
266 | |
---|