Exemplo n.º 1
0
 def validates(self, source):
     # Set form in each validator so that validators
     # like EqualToValidator can work
     for input in self.inputs:
         for validator in input.validators:
             validator.form = self
     return Form.validates(self, source)
Exemplo n.º 2
0
 def validates(self, source):
     # Set form in each validator so that validators
     # like EqualToValidator can work
     for input in self.inputs:
         for validator in input.validators:
             validator.form = self
     return Form.validates(self, source)
Exemplo n.º 3
0
 def __init__(self):
     Form.__init__(self, *self.INPUTS)
Exemplo n.º 4
0
 def __init__(self):
     Form.__init__(self, *self.INPUTS)
Exemplo n.º 5
0
from openlibrary.i18n import lgettext as _
from openlibrary.utils.form import Form, Textbox, Password, Hidden, Validator, RegexpValidator
from openlibrary import accounts
from openlibrary.accounts import InternetArchiveAccount
from . import spamcheck

def find_account(username=None, lusername=None, email=None):
    return accounts.find(username=username, lusername=lusername, email=email)

def find_ia_account(email=None):
    ia_account = InternetArchiveAccount.get(email=email)
    return ia_account

Login = Form(
    Textbox('username', description=_('Username'), klass='required'),
    Password('password', description=_('Password'), klass='required'),
    Hidden('redirect')
)
forms.login = Login

email_already_used = Validator(_("No user registered with this email address"), lambda email: find_account(email=email) is not None)
email_not_already_used = Validator(_("Email already registered"), lambda email: not find_ia_account(email=email))
email_not_disposable = Validator(_("Disposable email not permitted"), lambda email: not email.lower().endswith('dispostable.com'))
email_domain_not_blocked = Validator(_("Your email provider is not recognized."), lambda email: not spamcheck.is_spam_email(email))
username_validator = Validator(_("Username already used"), lambda username: not find_account(lusername=username.lower()))

vlogin = RegexpValidator(r"^[A-Za-z0-9-_]{3,20}$", _('Must be between 3 and 20 letters and numbers'))
vpass = RegexpValidator(r".{3,20}", _('Must be between 3 and 20 characters'))
vemail = RegexpValidator(r".*@.*", _("Must be a valid email address"))

class EqualToValidator(Validator):
Exemplo n.º 6
0
from infogami.infobase.client import ClientException
from infogami.core import forms

from openlibrary.i18n import lgettext as _
from openlibrary.utils.form import Form, Textbox, Password, Hidden, Validator, RegexpValidator


def find_account(username=None, lusername=None, email=None):
    import account
    return account.Account.find(username=username,
                                lusername=lusername,
                                email=email)


Login = Form(Textbox('username', description=_('Username'), klass='required'),
             Password('password', description=_('Password'), klass='required'),
             Hidden('redirect'))
forms.login = Login

email_already_used = Validator(
    _("No user registered with this email address"),
    lambda email: find_account(email=email) is not None)
email_not_already_used = Validator(
    _("Email already used"), lambda email: find_account(email=email) is None)
email_not_disposable = Validator(
    _("Disposable email not permitted"),
    lambda email: not email.lower().endswith('dispostable.com'))
username_validator = Validator(
    _("Username already used"),
    lambda username: not find_account(lusername=username.lower()))
Exemplo n.º 7
0
from openlibrary.accounts import InternetArchiveAccount
from . import spamcheck


def find_account(username=None, lusername=None, email=None):
    return accounts.find(username=username, lusername=lusername, email=email)


def find_ia_account(email=None):
    ia_account = InternetArchiveAccount.get(email=email)
    return ia_account


Login = Form(
    Textbox('username', description=_('Username'), klass='required'),
    Password('password', description=_('Password'), klass='required'),
    Hidden('redirect'),
)
forms.login = Login

email_already_used = Validator(
    _("No user registered with this email address"),
    lambda email: find_account(email=email) is not None,
)
email_not_already_used = Validator(
    _("Email already registered"),
    lambda email: not find_ia_account(email=email))
email_not_disposable = Validator(
    _("Disposable email not permitted"),
    lambda email: not email.lower().endswith('dispostable.com'),
)