Changeset 12414


Ignore:
Timestamp:
8 Jan 2015, 07:01:26 (10 years ago)
Author:
Henrik Bettermann
Message:

Validate all codes in Kofa.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r11804 r12414  
    166166    return True
    167167
     168# Define a validation method for ids
     169class NotIdValue(schema.ValidationError):
     170    __doc__ = u"Invalid id"
     171
     172#: Regular expressions to check id formats.
     173check_id = re.compile(r"^[a-zA-Z0-9_-]{2,6}$").match
     174
     175def validate_id(value):
     176    if not check_id(value):
     177        raise NotIdValue(value)
     178    return True
     179
    168180# Define a validation method for international phone numbers
    169181class InvalidPhoneNumber(schema.ValidationError):
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r11838 r12414  
    2121from zope import schema
    2222from zope.interface import Attribute, invariant, Invalid
    23 from waeup.kofa.interfaces import (IKofaObject, IKofaContainer)
     23from waeup.kofa.interfaces import IKofaObject, IKofaContainer, validate_id
    2424from waeup.kofa.interfaces import MessageFactory as _
    2525from waeup.kofa.university.vocabularies import (
     
    3939        default = u'NA',
    4040        required = True,
     41        constraint=validate_id,
    4142        )
    4243
     
    6970        default = u'NA',
    7071        required = True,
     72        constraint=validate_id,
    7173        )
    7274
     
    112114        default = u'NA',
    113115        required = True,
     116        constraint=validate_id,
    114117        )
    115118
     
    156159        default = u'NA',
    157160        required = True,
     161        constraint=validate_id,
    158162        )
    159163
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r12191 r12414  
    271271        errs, inv_errs, conv_dict =  converter.fromStringDict(
    272272            row, self.factory_name, mode=mode)
    273         if 'code' in row and ' ' in row['code']:
    274             errs.append(('code','must not contain spaces'))
    275273        return errs, inv_errs, conv_dict
    276274
Note: See TracChangeset for help on using the changeset viewer.