Changeset 17764 for main/waeup.kofa/trunk/src/waeup/kofa/utils
- Timestamp:
- 11 May 2024, 19:56:39 (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/converters.py
r16818 r17764 29 29 from zope.schema.interfaces import IList 30 30 from waeup.kofa.interfaces import ( 31 IObjectConverter, IResultEntryField, IFieldConverter, SubjectSource, 31 IObjectConverter, IResultEntryField, IRefereeEntryField, 32 IFieldConverter, SubjectSource, 32 33 GradeSource, DELETION_MARKER, IGNORE_MARKER) 33 34 from waeup.kofa.schema.interfaces import IPhoneNumber 34 35 from waeup.kofa.schoolgrades import ResultEntry 36 from waeup.kofa.refereeentries import RefereeEntry 35 37 36 38 class ExtendedCheckBoxWidget(CheckBoxWidget): … … 203 205 "%ssubject" % (prefix): s_token, 204 206 "%sgrade" % (prefix): g_token, 207 } 208 return result 209 210 class RefereeEntryConverter(grok.Adapter): 211 grok.context(IRefereeEntryField) 212 grok.implements(IFieldConverter) 213 214 def request_data(self, name, value, schema_field, prefix='', 215 mode='create'): 216 """Turn CSV values into RefereeEntry-compatible form data. 217 See ResultEntryConverter. 218 """ 219 try: 220 entry = RefereeEntry.from_string(value) 221 name, email, email_sent = entry.name, entry.email, entry.email_sent 222 except: 223 return {prefix: value} 224 result = { 225 "%sname" % (prefix): name, 226 "%semail" % (prefix): email, 205 227 } 206 228 return result
Note: See TracChangeset for help on using the changeset viewer.