Ejemplo n.º 1
0
    def validate_email(self, field):
        allowed_email = UserAdmin.find_allowed_email(field.data)
        if allowed_email:
            if allowed_email.confirmed_at != None:
                raise ValidationError(
                    _('Email address has been confirmed earlier'))
            elif (allowed_email.creator
                  == 'system') and not allowed_email.approved:
                raise ValidationError(
                    _('Email address has not been approved yet'))
#            if (allowed_email.creator != 'system') or allowed_email.approved:
            else:
                return True
        raise ValidationError(_('Email address must be an authorized one'))
Ejemplo n.º 2
0
 def validate_agree(self, field):
     if not field.data:
         raise ValidationError(
             _('Please indicate that you have read and agree to the Terms and Conditions'
               ), 'error')
     else:
         return True
Ejemplo n.º 3
0
class ExtendedConfirmRegisterForm(ConfirmRegisterForm):

    email = StringField(_l('Email address'),
                        validators=[Required('Email required')])
    agree = BooleanField(
        _l("I have read and agree the <a href='static/termsofuse.html'>Terms of use</a>"
           ))
    password = PasswordField(_l('Password'),
                             validators=[Required('Password required')])
    submit = SubmitField(_l('Register'))

    def validate_agree(self, field):
        if not field.data:
            raise ValidationError(
                _('Please indicate that you have read and agree to the Terms and Conditions'
                  ), 'error')
        else:
            return True

    def validate_email(self, field):
        allowed_email = UserAdmin.find_allowed_email(field.data)
        if allowed_email:
            if allowed_email.confirmed_at != None:
                raise ValidationError(
                    _('Email address has been confirmed earlier'))
            elif (allowed_email.creator
                  == 'system') and not allowed_email.approved:
                raise ValidationError(
                    _('Email address has not been approved yet'))
#            if (allowed_email.creator != 'system') or allowed_email.approved:
            else:
                return True
        raise ValidationError(_('Email address must be an authorized one'))

    def validate_username(self, field):
        user = shareds.user_datastore.get_user(field.data)
        if user:
            raise ValidationError(_('Username has been reserved already'))

    username = StringField(_l('Username'),
                           validators=[Required('Username required')])
    name = StringField(_l('Name'), validators=[Required('Name required')])
    language = SelectField(_l('Language'),
                           choices=shareds.app.config.get('LANGUAGES'),
                           validators=[Required(_('Language required'))])
Ejemplo n.º 4
0
def state_terms_filter(field):
    def inner(values):
        if 'filling' in values:
            return Bool(should=[
                Q('terms', **{field: values}),
                Bool(must_not=[Q('exists', field='state')])
            ],
                        minimum_should_match=1)
        else:
            return Q('terms', **{field: values})

    return inner


FILTERS = {
    _('category'): terms_filter('category'),
    _('creator'): terms_filter('creator.raw'),
    _('title'): language_aware_text_match_filter('title'),
    _('state'): state_terms_filter('state'),
    # draft
    **DRAFT_IMPORTANT_FILTERS
}


def term_facet(field, order='desc', size=100, missing=None):
    ret = {
        'terms': {
            'field': field,
            'size': size,
            "order": {
                "_count": order
Ejemplo n.º 5
0
 def __str__(self):
     """ Role name in ui language """
     return _(self.name)
Ejemplo n.º 6
0
def security_register_processor():
    return {
        "username": _('User name'),
        "name": _('Name'),
        "language": _('Language')
    }
Ejemplo n.º 7
0
 def validate_username(self, field):
     user = shareds.user_datastore.get_user(field.data)
     if user:
         raise ValidationError(_('Username has been reserved already'))
Ejemplo n.º 8
0
class RegisterForm(forms.RegisterForm):

    # add new inputForm `full name`
    fullname = StringField(
        utils._('Full Name'),
        validators=[forms.Required('fullname not provided')])