Ejemplo n.º 1
0
def unique_with_database(form, field):
    message = "An event with that slug already exists."
    from app.models import Event, EventSeries
    if EventSeries.objects(slug=field.data).count() != 0:
        raise ValidationError(message)
    if Event.objects(slug=field.data).count() != 0:
        raise ValidationError(message)
Ejemplo n.º 2
0
def unique_with_database(form, field):
    message = "An event with that slug already exists."
    from app.models import Event, EventSeries
    if EventSeries.objects(slug=field.data).count() != 0:
        raise ValidationError(message)
    if Event.objects(slug=field.data).count() != 0:
        raise ValidationError(message)
Ejemplo n.º 3
0
    def __call__(self, form, field):
        """Called internally by :mod:`wtforms` on validation of the field.

        :param form: The parent form
        :type form: :class:`Form`
        :param field: The field to validate
        :type field: :class:`Field`

        :raises: :class:`wtforms.validators.ValidationError`
        """
        from app.models import Event, EventSeries

        if EventSeries.objects(slug=field.data).count():
            raise ValidationError(self.message)
        if Event.objects(slug=field.data).count():
            raise ValidationError(self.message)
Ejemplo n.º 4
0
    def __call__(self, form, field):
        """Called internally by :mod:`wtforms` on validation of the field.

        :param form: The parent form
        :type form: :class:`Form`
        :param field: The field to validate
        :type field: :class:`Field`

        :raises: :class:`wtforms.validators.ValidationError`
        """
        from app.models import Event, EventSeries

        if EventSeries.objects(slug=field.data).count():
            raise ValidationError(self.message)
        if Event.objects(slug=field.data).count():
            raise ValidationError(self.message)
Ejemplo n.º 5
0
    def __call__(self, form, field):
        """Called internally by :mod:`wtforms` on validation of the field.

        :param form: The parent form
        :type form: :class:`Form`
        :param field: The field to validate
        :type field: :class:`Field`

        :raises: :class:`wtforms.validators.ValidationError`
        """
        from app.models import Event, EventSeries

        # If we change the slug, make sure the new slug doesn't exist
        if self.original.slug != field.data:
            if EventSeries.objects(slug=field.data).count():
                raise ValidationError(self.message)
            if Event.objects(slug=field.data).count():
                raise ValidationError(self.message)
Ejemplo n.º 6
0
    def __call__(self, form, field):
        """Called internally by :mod:`wtforms` on validation of the field.

        :param form: The parent form
        :type form: :class:`Form`
        :param field: The field to validate
        :type field: :class:`Field`

        :raises: :class:`wtforms.validators.ValidationError`
        """
        from app.models import Event, EventSeries

        # If we change the slug, make sure the new slug doesn't exist
        if self.original.slug != field.data:
            if EventSeries.objects(slug=field.data).count():
                raise ValidationError(self.message)
            if Event.objects(slug=field.data).count():
                raise ValidationError(self.message)