Esempio n. 1
0
class LocationSchema(Schema):
    description = UnicodeString(max=256)
    purpose = OneOf(_flatten(models.Location.PURPOSE_CHOICES))
    relative_path = UnicodeString()
    quota = Int(min=0)
    enabled = Bool()
    space = ResourceURI(model_cls=models.Space)
    pipeline = ForEach(ResourceURI(model_cls=models.Pipeline))
    replicators = ForEach(ResourceURI(model_cls=models.Location))
Esempio n. 2
0
class UserSchema(Schema):
    username = Regex(r'^[a-zA-Z0-9_@+\.-]+$', max=150)
    password = UnicodeString()
    first_name = UnicodeString(max=30)
    last_name = UnicodeString(max=150)
    email = Email()
    groups = ForEach(ResourceURI(model_cls=Group))
    user_permissions = ForEach(ResourceURI(model_cls=Permission))
    is_staff = Bool()
    is_active = Bool()
    is_superuser = Bool()
Esempio n. 3
0
class NewFormForm(Schema):
    """NewFormForm is a Schema for validating the data entered at the Add Form
    page.
    
    """

    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]
    transcription = UnicodeString(
        not_empty=True, messages={'empty': 'Please enter a transcription.'})
    phoneticTranscription = UnicodeString()
    narrowPhoneticTranscription = UnicodeString()
    morphemeBreak = UnicodeString()
    grammaticality = UnicodeString()
    morphemeGloss = UnicodeString()
    glosses = FirstGlossNotEmpty()
    comments = UnicodeString()
    speakerComments = UnicodeString()
    context = UnicodeString()
    elicitationMethod = UnicodeString()
    keywords = ForEach(Keyword())
    syntacticCategory = UnicodeString()
    speaker = UnicodeString()
    elicitor = UnicodeString()
    verifier = UnicodeString()
    source = UnicodeString()
    dateElicited = DateConverter(month_style='mm/dd/yyyy')
Esempio n. 4
0
class SearchFileForm(Schema):
    """SearchFile is a Schema for validating the search terms entered at the Search Files page."""
    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]
    searchTerm1 = UnicodeString()
    searchType1 = UnicodeString()
    searchLocation1 = UnicodeString()
    searchTerm2 = UnicodeString()
    searchType2 = UnicodeString()
    searchLocation2 = UnicodeString()
    andOrNot = UnicodeString()
    restrictors = ForEach(RestrictorStruct())
    dateRestrictors = ForEach(DateRestrictorStruct())
    integerRestrictors = ForEach(IntegerRestrictorStruct())
    orderByColumn = UnicodeString()
    orderByDirection = UnicodeString()
Esempio n. 5
0
 def post_init(self, *args, **kw):
     # Only override the user-provided validator if it's not a ForEach one,
     # which usually means the user needs to perform validation on the list
     # as a whole.
     self._original_validator = self.validator
     if not (isinstance(self.validator, ForEach) or
             (isclass(self.validator)
              and issubclass(self.validator, ForEach))):
         self.validator = ForEach(self.validator)
Esempio n. 6
0
class AddEvidenceForm(Schema):
    reference = v.UnicodeString(not_empty=True)
    bag_num = v.UnicodeString()
    type = GetEvidenceType(not_empty=True)
    originator = v.UnicodeString(not_empty=True)
    comments = v.UnicodeString(not_empty=True)
    location = v.UnicodeString(not_empty=True)
    qr = v.Bool()
    photo = ForEach(UploadEvidencePhoto())
Esempio n. 7
0
class ExpenditureSchema(AuthFormSchema):
    "Validate an expenditure."
    allow_extra_fields = False
    pre_validators = [NestedVariables()]
    spender_id = validators.Int(not_empty=True)
    amount = model.types.CurrencyValidator(not_empty=True)
    description = validators.UnicodeString(not_empty=True)
    date = validators.DateConverter()
    shares = ForEach(ShareSchema)
    chained_validators = [ValidateNotAllZero]
Esempio n. 8
0
class BlogPost(Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    title = validators.UnicodeString(
        max=255,
        min=2,
        not_empty=True,
        messages={'empty': u'Please enter a title for your blog post'})
    body = validators.UnicodeString(
        min=5, not_empty=True, messages={'empty': u'Enter your blog post'})
    category_id = ForEach(validators.Int())
Esempio n. 9
0
class QuestionPost(Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    title = validators.UnicodeString(
        max=255,
        min=2,
        not_empty=True,
        messages={'empty': u'Please ask your question'})
    body = validators.UnicodeString()
    category_id = ForEach(validators.Int())
    state_id = validators.Int()
    city = validators.UnicodeString(max=50)
    anonymous = validators.Int(if_missing=0)
Esempio n. 10
0
class PackageSchema(Schema):
    current_location = ResourceURI(model_cls=models.Location)
    current_path = UnicodeString()
    description = UnicodeString(max=256)
    encryption_key_fingerprint = UnicodeString(max=512)
    misc_attributes = UnicodeString()
    origin_pipeline = ResourceURI(model_cls=models.Pipeline)
    package_type = OneOf(_flatten(models.Package.PACKAGE_TYPE_CHOICES))
    pointer_file_location = ResourceURI(model_cls=models.Location)
    pointer_file_path = UnicodeString()
    related_packages = ForEach(ResourceURI(model_cls=models.Package))
    replicated_package = ResourceURI(model_cls=models.Package)
    size = Int(min=0)
    status = OneOf(_flatten(models.Package.STATUS_CHOICES))
 class MySchema(Schema):
     pre_validators = [NestedVariables()]
     people = ForEach(SubSchema(),
                      if_missing=NoDefault,
                      messages={'missing': 'Please add a person'})
Esempio n. 12
0
class AlterSettingsForm(Schema):
    """AlterSettingsForm is a Schema for validating the data entered at the
    system settings page.

    """

    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]

    OLName = UnicodeString()
    OLId = UnicodeString()

    MLName = UnicodeString()
    MLId = UnicodeString()
    MLOrthography = UnicodeString()

    headerImageName = UnicodeString()
    colorsCSS = UnicodeString()

    orthographyOptions = [u'Orthography %s' % unicode(i) for i \
                          in range(1,6)]
    storageOrthography = OneOf(orthographyOptions)
    defaultInputOrthography = UnicodeString()
    defaultOutputOrthography = UnicodeString()

    objectLanguageOrthography1Name = UnicodeString()
    objectLanguageOrthography1 = UnicodeString()
    OLO1Lowercase = StringBoolean(if_missing=False)
    OLO1InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography2Name = UnicodeString()
    objectLanguageOrthography2 = UnicodeString()
    OLO2Lowercase = StringBoolean(if_missing=False)
    OLO2InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography3Name = UnicodeString()
    objectLanguageOrthography3 = UnicodeString()
    OLO3Lowercase = StringBoolean(if_missing=False)
    OLO3InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography4Name = UnicodeString()
    objectLanguageOrthography4 = UnicodeString()
    OLO4Lowercase = StringBoolean(if_missing=False)
    OLO4InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography5Name = UnicodeString()
    objectLanguageOrthography5 = UnicodeString()
    OLO5Lowercase = StringBoolean(if_missing=False)
    OLO5InitialGlottalStops = StringBoolean(if_missing=False)

    morphemeBreakIsObjectLanguageString = UnicodeString()

    unrestrictedUsers = ForEach(UnrestrictedUser())

    orthographicValidation = OneOf([u'None', u'Warning', u'Error'])
    narrPhonInventory = UnicodeString()
    narrPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    broadPhonInventory = UnicodeString()
    broadPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    morphPhonInventory = UnicodeString()
    morphDelimiters = UnicodeString()
    morphPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    punctuation = UnicodeString()
    grammaticalities = UnicodeString()
Esempio n. 13
0
class RestrictorStruct(Schema):
    location = UnicodeString()
    containsNot = UnicodeString()
    allAnyOf = UnicodeString
    options = ForEach(UnicodeString())
Esempio n. 14
0
 def post_init(self, *args, **kw):
     if self.validator is DefaultValidator and _has_child_validators(self):
         log.debug("Generating a ForEach validator for %r", self)
         self.validator = ForEach(self.children[0].validator)