Exemple #1
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 eventum.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)
Exemple #2
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 eventum.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)
Exemple #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 eventum.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)
Exemple #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 eventum.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)