- Timestamp:
- 20 Jun 2012, 11:27:11 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r8742 r8767 33 33 from waeup.kofa.payments.interfaces import IOnlinePayment 34 34 from waeup.kofa.schema import PhoneNumber 35 from waeup.kofa.students.vocabularies import GenderSource 35 from waeup.kofa.students.vocabularies import GenderSource, RegNumberSource 36 36 from waeup.kofa.university.vocabularies import AppCatSource, CertificateSource 37 37 … … 48 48 pass 49 49 50 class RegNumberSource(object): 51 implements(ISource) 50 class ApplicantRegNumberSource(RegNumberSource): 51 """A source that accepts any reg number if not used already by a 52 different applicant. 53 """ 52 54 cat_name = 'applicants_catalog' 53 55 field_name = 'reg_number' 54 56 validation_error = RegNumInSource 55 def __init__(self, context): 56 self.context = context 57 return 58 59 def __contains__(self, value): 60 cat = queryUtility(ICatalog, self.cat_name) 61 if cat is None: 62 return True 63 kw = {self.field_name: (value, value)} 64 results = cat.searchResults(**kw) 65 for entry in results: 66 if entry.applicant_id != self.context.applicant_id: 67 # XXX: sources should simply return False. 68 # But then we get some stupid error message in forms 69 # when validation fails. 70 raise self.validation_error(value) 71 #return False 72 return True 57 comp_field = 'applicant_id' 73 58 74 59 def contextual_reg_num_source(context): 75 source = RegNumberSource(context)60 source = ApplicantRegNumberSource(context) 76 61 return source 77 62 directlyProvides(contextual_reg_num_source, IContextSourceBinder)
Note: See TracChangeset for help on using the changeset viewer.