Ejemplo n.º 1
0
            def validate(self):
                """Validate the form"""
                res = True
                if not Form.validate(self):
                    res = False

                report_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all()

                tags = [
                    Tag.get_or_create(tag.strip()) for tag in self.tags.data
                    if tag.strip()
                ]

                user = User.query.get(self.user_id.data)
                if not user:
                    self.user_id.errors.append("User not found!")
                    res = False

                self.report = Report(
                    user=user,
                    name=self.name.data,
                    fields=report_fields,
                    tags=tags,
                )

                return res
Ejemplo n.º 2
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        if self.url.data in relevant_feeds():
            self.url.errors.append("מקור מידע קיים במנוי")
            return False

        url = urlparse(self.url.data).geturl()
        try:
            myjson = urllib.request.urlopen(url).read().decode('utf-8')
        except URLError:
            self.url.errors.append("כתובת לא קיימת")
            return False
        try:
            json_object = json.loads(myjson)
            return True
        except ValueError:
            pass
        try:
            myatom = feedparser.parse(url)
            if myatom.status != 200:
                self.url.errors.append('המקור שהוזן אינו בפורמט ATOM')
                return False
        except ValueError:
            self.url.errors.append('המקור שהוזן אינו בפורמט JSON או ATOM')
            return False

        self.url=url
        return True
Ejemplo n.º 3
0
            def validate(self):
                """Validate the form"""

                if not Form.validate(self):
                    return False

                self.chart = Chart.query.get(self.chart_id.data)

                chart_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all()
                tags = [
                    Tag.get_or_create(tag.strip()) for tag in self.tags.data
                    if tag.strip()
                ]

                res = True
                ctype = ChartType.query.get(self.chart_type.data)
                if not ctype:
                    self.chart_type.errors.append("Chart Type not found!")
                    res = False

                self.chart.name = self.name.data
                self.chart.with_table = self.with_table.data
                self.chart.ctype = ctype
                self.chart.fields = chart_fields
                self.chart.tags = tags

                return res
Ejemplo n.º 4
0
    def validate(self):
        res = True
        if not Form.validate(self):
            res = False

        query = User.query.join(Profile)
        query = query.filter(User.id != current_user.id)
        query = query.filter(Profile.domain == current_user.profile.domain)
        query = query.filter(User.banned == False)

        if self.username.data.strip() != '':
            query = query.filter(User.username == self.username.data.strip())

        if self.email.data.strip() != '':
            query = query.filter(User.email == self.email.data.strip())

        if self.gender.data != 3:
            query = query.filter(Profile.gender == self.gender.data)

        interests = filter(None, self.interests_text.data.splitlines())
        if len(interests) > 0:
            query = query.join(Interest, Profile.interests).filter(
                or_(
                    Interest.name == interest
                    for interest in interests
                )
            )

        self.users = query.all()
        return res
Ejemplo n.º 5
0
Archivo: forms.py Proyecto: Morgl/charo
	def validate(self):
		rv = Form.validate(self)
		if rv and self.username.data == blog.config['USERNAME'] \
		and password_match_hash(self.password.data,
								blog.config['PASSWORD_HASH_SHA512']):
	 		return True
		return False
Ejemplo n.º 6
0
            def validate(self):
                """Validate the form"""
                res = True
                if not Form.validate(self):
                    res = False

                for field in self.instance_fields:
                    formfield = getattr(self, field.name)
                    if formfield.data is not None:
                        # Check for any old values that should now be deleted
                        stale_value = field.data_points.filter_by(
                            ds=self.ds.data,
                        ).first()
                        if stale_value is not None:
                            self.stale_values.append(stale_value)

                        # Create the new data point
                        data_point = FieldData(
                            ds=self.ds.data,
                            field=field,
                            value=formfield.data,
                        )
                        self.data_points.append(data_point)

                return res
Ejemplo n.º 7
0
    def validate(self):
        # Standard Validation
        rv = Form.validate(self)
        if not rv:
            return False

        # user validation
        user = User.query.filter_by(email=self.email.data).first()
        if user is None:
            self.email.errors.append('Your login details are incorrect.')
            return False

        # account validation
        if user.token is not None:
            self.email.errors.append('Please confirm your account before '
                                     'loggin in.')
            resend_url = url_for('.resend_confirmation') + '?email=' +\
                self.email.data
            self.email.errors.append(
                'If you do not revieve your confirmation email you can resend '
                'it by clicking <a href="' + resend_url + '">here</a>')
            return False

        # password validation
        if not bcrypt.check_password_hash(
            user.password, self.password.data
        ):
            self.password.errors.append('Your login details are incorrect.')
            return False

        self.user = user
        return True
Ejemplo n.º 8
0
Archivo: forms.py Proyecto: adlnet/xci
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        if models.checkUsernameExists(self.username.data):
            self.username.errors.append('Username already exists')
            return False

        if models.checkEmailExists(self.email.data):
            self.email.errors.append('Email already exists')
            return False


        role = self.role.data
        if role == 'admin':
            role = ['admin', 'teacher', 'student']
        elif role == 'teacher':
            role = ['teacher', 'student']
        else:
            role = ['student']

        self.user = models.User(self.username.data, password=self.password.data, email=self.email.data,
            first_name=self.first_name.data, last_name=self.last_name.data, roles=role)
        return True 
Ejemplo n.º 9
0
    def validate(self):
        # Standard Validation
        rv = Form.validate(self)
        if not rv:
            return False

        # user validation
        user = User.query.filter_by(email=self.email.data).first()
        if user is None:
            self.code.errors.append(
                'We don\'t have that email address in our system.'
            )
            return False

        forgot = ResetPassword.query.filter_by(
            user=user,
            code=self.code.data
        ).first()
        if forgot is None:
            self.forgot.errors.append(
                'There has been no request to reset your password.'
            )
            return False

        if datetime.utcnow() > forgot.expires:
            self.forgot.errors.append(
                'That reset token has expired. <a href="{}">Click here</a>'
                ' to send a new reset link.'.format(
                    url_for('users.forgot_password')
                )
            )
            return False

        self.user = user
        return True
Ejemplo n.º 10
0
    def validate(self):
        zip_pattern = re.compile("[0-9]*")
        specialty_pattern = re.compile("[A-Za-z/]*")
        
        if self.zipcode.data.strip() == '':
            self.zipcode.errors = "Please enter zipcode"
            return False

        if self.specialty.data.strip() == '':
            self.specialty.errors = "Please enter specialty"
            return False
        
        if len(zip_pattern.match(self.zipcode.data).group(0)) == 0:
            self.zipcode.errors = "Invalid zipcode, zipcode should be numbers"
            return False

        if len(specialty_pattern.match(self.specialty.data).group(0)) == 0:
            self.specialty.errors = ("Invalid specialty, numbers or symbols aren't allowed")
            return False

        if not Form.validate(self):
            return False

        try:
            zip = long(self.zipcode.data.strip())
            return True
        except Exception as e:
            return False
Ejemplo n.º 11
0
 def validate(self, extra_validators=None):
     valid = Form.validate(self)
     project = ImportMapper.get_project_by_id(self.project_id) if self.project_id else Project()
     if project.name != self.name.data and ImportMapper.get_project_by_name(self.name.data):
         self.name.errors.append(_('error name exists'))
         valid = False
     return valid
Ejemplo n.º 12
0
    def validate(self, **kwargs):
        valid = Form.validate(self)
        if self.confirm.data != self.password.data:
            self.confirm.errors.append("Confirmation doesn't match password")
            valid = False

        return valid
Ejemplo n.º 13
0
    def validate(self, **kwargs):
        valid = Form.validate(self)
        if User.query.filter_by(email=self.email.data).first() is not None:
            self.email.errors.append("Email belongs to an existing user")
            valid = False

        return valid
Ejemplo n.º 14
0
    def validate(self):
        if not Form.validate(self):
            return False

        # check if username has valid characters
        if not validate_username_characters(self.username.data):
            self.username.errors.append(gettext(u'Username contains illegal characters.'))
            return False

        if not validate_username_blocked(self.username.data):
            self.username.errors.append(gettext(u'Username is blocked.'))
            return False

        # check username
        user = User.query.filter_by(username=self.username.data).first()
        if user is not None:
            self.username.errors.append(gettext(u'Username is already in use.'))
            return False

        # email check
        user = User.query.filter_by(email=self.email.data.lower()).first()
        if user is not None:
            self.email.errors.append(gettext(u'Email is already in use.'))
            return False

        return True
Ejemplo n.º 15
0
 def validate(self):
     """Validate the input and authenticate the user."""
     if Form.validate(self):
         if auth.is_valid_login(self.username.data, self.password.data):
             return True
     self.username.errors.insert(0, 'Invalid credentials, try again')
     return False
Ejemplo n.º 16
0
    def validate(self):
        if not Form.validate(self):
            return False

        # check if username has valid characters
        if not validate_username_characters(self.username.data):
            self.username.errors.append(gettext(u'Username contains illegal characters.'))
            return False

        if not validate_username_blocked(self.username.data):
            self.username.errors.append(gettext(u'Username is blocked.'))
            return False

        # check username
        user = User.query.filter_by(username=self.username.data).first()
        if (user is not None) and (user.id != current_user.id):
            self.username.errors.append(gettext(u'Username is already in use.'))
            return False

        # email check
        user = User.query.filter_by(email=self.email.data.lower()).first()
        if (user is not None) and (user.id != current_user.id):
            self.email.errors.append(gettext(u'Email is already in use.'))
            return False

        # check old password
        if ((self.old_password.data is not None) and self.old_password.data
                and (not check_password_hash(current_user.password, self.old_password.data))):
            self.old_password.errors.append(gettext(u'Old password is not correct.'))
            return False

        return True
Ejemplo n.º 17
0
 def validate(self):
     if not Form.validate(self):
         return False
     if Users.exists(email=self.email.data):
         self.email.errors.append('このメールアドレスが既に登録されています。')
         return False
     return True
Ejemplo n.º 18
0
    def validate(self, extra_validators=None):
        if not Form.validate(self):
            return False

        voter = Voter.query.filter_by(email=self.email.data).first()

        if voter is None:
            self.email.errors.append("Unknown email address")
            return False

        # Check the user isn't recycling their passcode
        if voter.passcode_used:
            self.passcode.errors.append("Your passcode has already been used, please log in again from the start")
            return False

        # Check the user has 'just' got the email
        if voter.passcode_generated > datetime.datetime.now() + datetime.timedelta(minutes=5):
            self.passcode.errors.append("Your passcode has expired, please log in again")
            return False

        if voter.passcode != self.passcode.data:
            self.passcode.errors.append("Your passcode is incorrect")
            return False

        # Mark the passcode as used (since it's validated successfully)
        voter.passcode_used = True
        db.session.add(voter)
        db.session.commit()

        return True
Ejemplo n.º 19
0
  def validate(self):
    """
    Custom validation, overwrites standard WTForm validator.

    returns:
      False: If not valid as per input type.
             If password repeat does not match.
             User already created.

      True: User created.

    """
    if not Form.validate(self):
      return False

    if self.password.data != self.password2.data:
      self.password.errors.append("The two passwords does not match")
      return False  

    user = User.query.filter_by(email = self.email.data.lower()).first()

    if user:
      self.email.errors.append("User already created")
      return False
    else:
      return True
Ejemplo n.º 20
0
    def validate(self):
        if not Form.validate(self):
            return False

        if len(self.phone.data) != 10 or not self.phone.data.isdigit():
            self.phone.errors.append('Phone number must be 10 digits, without other characters.')
            return False
Ejemplo n.º 21
0
    def validate(self, curuser):
        result = True
        if not Form.validate(self):
            return False
        sum = (self.sum_nds18.data + self.sum_no_nds18.data +
              self.sum_nds10.data + self.sum_no_nds10.data)
        if not sum == self.sum_snds.data:
            self.sum_snds.errors.append(u"Неверно указана сумма с НДС. Расчетная сумма "+str(sum))
            result = False
        sum18 = round(self.sum_no_nds18.data*decimal.Decimal(str(0.18)),2)
        fault = math.fabs(sum18-(float(self.sum_nds18.data)))
        if fault>0.05:
            self.sum_nds18.errors.append(u"Неверно указана сумма НДС 18%. Расчетная сумма "+str(sum18))
            result = False
        sum10 = round(self.sum_no_nds10.data*decimal.Decimal(str(0.10)),2)
        fault = math.fabs(sum10-(float(self.sum_nds10.data)))
        if fault>0.05:
            self.sum_nds10.errors.append(u"Неверно указана сумма НДС 10%. Расчетная сумма "+str(sum10))
            result = False

        if self.ninvoice is not None:
            invoice = Invoice.query.filter(Invoice.ninvoice==self.ninvoice.data, Invoice.agent_uid==self.agent_uid.data,
                                       Invoice.org_uid==self.org_uid.data, Invoice.uid!=self.uid.data).first()
            if invoice is not None:
                self.ninvoice.errors.append(u"Счет фактура с указанным номером уже добавлена")
                result = False

        if not curuser.allow_edit:
            if self.dinvoice.data>Settings.dend().date() or self.dinvoice.data<Settings.dbegin().date():
                self.dinvoice.errors.append(u"Закрытый период. Ввод и изменение данных запрещены!")
                result = False

        return result
Ejemplo n.º 22
0
    def validate(self):
        """Validate the form"""
        if not Form.validate(self):
            return False

        if not self.confirm.data:
            self.confirm.errors.append('You must confirm your intentions')
            return False

        new_team = Team.query.get(int(self.team_id.data))
        if not new_team:
            self.team_id.errors.append('Team not found')
            return False

        if current_user.team and new_team.id == current_user.team.id:
            self.team_id.errors.append("You're already a member of this team")
            return False

        if len(new_team.users) == 2:
            self.team_id.errors.append('Oops! That team is already full!')
            return False

        if new_team.school.id != current_user.school.id:
            self.team_id.errors.append("Sorry, you can't join a team from another school")
            return False

        current_user.team = new_team
        return True
Ejemplo n.º 23
0
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     #check if variable with the same name already exists:
     var = findVariable(self.projectId, self.name.data)
     if not var == None:
         self.name.errors.append('Variable with this name already exists within this project!')
         return False
     if not self.vType == None:
         typ = self.vType.data.lower()
     else:
         typ = None
     if typ == 'number':
         #just check if value can be converted:
         try:
             float(self.value.data)
         except:
             self.value.errors.append('Must be a number if variable type is number')
             return False
     elif typ == 'boolean':
         #just check if value can be converted:
         if self.value.data not in ['1', '0', 'True', 'False', 'true', 'false']:
             self.value.errors.append('Must be logic value if variable type is boolean')
             return False
     #return true if there are no errors
     return True
Ejemplo n.º 24
0
    def validate(self):
        res = True
        if not Form.validate(self):
            res = False

        self.message = self.message_text.data
        return res
Ejemplo n.º 25
0
    def validate(self):
        """Validate the form."""
        rv = Form.validate(self)
        if not rv:
            return False

        return True
Ejemplo n.º 26
0
    def validate(self, **kwargs):
        valid = Form.validate(self)
        if Asset.query.filter_by(code=self.code.data).filter(Asset.id != self.asset_id).first() is not None:
            self.code.errors.append("Andela Serial Code must be unique")
            valid = False

        return valid
Ejemplo n.º 27
0
    def validate(self):
        """Validate the form"""
        res = True
        if not Form.validate(self):
            res = False

        user = User.query.get(self.user_id.data)
        if user is None:
            self.user_id.errors.append('User not found')
            res = False

        location = Location.query.get(self.location.data)
        if location is None:
            self.location.errors.append('Location not found')
            res = False

        department = Department.query.get(self.department.data)
        if department is None:
            self.department.errors.append('Department not found')

        # Set all of the values now that validation is complete
        user.name = self.name.data or user.name
        user.location = location
        user.department = department

        if self.password.data:
            user.set_password(self.password.data)

        return res
Ejemplo n.º 28
0
    def validate(self):
        if not Form.validate(self):
            return False

        if self.nickname.data != User.make_valid_nickname(self.nickname.data):
            self.nickname.errors.append(
                'Please use letters, numbers, dots and underscores only'
            )
            return False

        if self.password.data != self.confirm_pass.data:
            self.confirm_pass.errors.append('Passwords should be identical')
            return False

        user = User.query.filter_by(nickname=self.nickname.data).first()
        if user is not None:
            self.nickname.errors.append('This nickname is already in use')
            return False

        user = User.query.filter_by(email=self.email.data).first()
        if user is not None:
            self.email.errors.append('This Email is already in use')
            return False

        return True
Ejemplo n.º 29
0
    def validate(self):
        if not Form.validate(self):
            return False
        
        _c_id = self.c_id.data
        _c_type = self.c_type.data
        _sem = self.sem.data
        _cred = self.cred.data

        rv = True

        courses = {}
        with open("files/courses.json", "r") as f:
            courses = json.load(f)
        if str(_c_id) in courses:
            self.c_id.errors.append(
                "Course already registered."
                )
            rv = False

        limit = {"UG": 8, "PG": 4}
        lim = limit[_c_type]
        if _sem not in xrange(1, lim+1):
            self.sem.errors.append(
                "Incorrect sem. Should be between 1-" + str(lim) + " for " + _c_type
                )
            rv = False

        if _cred not in xrange(1, 5):
            self.cred.errors.append(
                "Incorrect credits, should be between 1 and 4 only."
                )
            rv = False

        return rv
Ejemplo n.º 30
0
 def validate(self):
     if not Form.validate(self):
         # for field, errors in self.errors.items():
         #     print field, errors
         return False
     else:
         return True
Ejemplo n.º 31
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = User.query.filter_by(username = self.username.data.lower()).first()
        if user and user.check_password(self.password.data):
            return True
        else:
            self.username.errors.append("Invalid username or password")
            return False
Ejemplo n.º 32
0
    def validate(self):
        # 检测表单是否被提交
        if not Form.validate(self):
            return False

        user = User.query.filter_by(email = self.email.data).first()
        if user and user.check_password(self.password.data):
            return True
        else:
            return False
Ejemplo n.º 33
0
 def validate(self):
     if (not Form.validate(self)):
         return False
     if (self.nickname.data == self.original_nickname):
         return True
     user = User.query.filter_by(nickname=nickname.data).first()
     if (user != None):
         self.nickname.errors.append('This nickname is already in use. Please choose another one')
         return False
     return True
Ejemplo n.º 34
0
	def validate(self):
		if not Form.validate(self):
			return False
      		
		#check if username/email is taken or not
		if app_users.query.filter_by(email = self.email.data).first() is not None:
			self.email.errors.append("That email is already taken")
			return False
		else:
			return True
Ejemplo n.º 35
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = AdminUser.query.filter_by(email=self.email.data.lower()).first()
        if user and user.check_password(self.password.data):
            return True
        else:
            self.email.errors.append("Invalid e-mail or password")
            return False
Ejemplo n.º 36
0
 def validate(self):
   if not Form.validate(self):
     return False
    
   user = User.query.filter_by(email = self.email.data.lower()).first()
   if user:
     self.email.errors.append("That email is already taken")
     return False
   else:
     return True
Ejemplo n.º 37
0
 def validate(self):
     if not Form.validate(self):
         return False
     if self.nickname.data == self.original_nickname:
         return True
     user = User.query.filter_by(nickname=self.nickname.data).first()
     if user != None:
         self.nickname.errors.append('This nickname is already in use')
         return False
     return True
Ejemplo n.º 38
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        if self.password.data and self.password_reply.data and self.password.data != self.password_reply.data:
            self.password.errors.append(u'Пароли не совпадают')
            self.password_reply.errors.append(u'Пароли не совпадают')
            return False
        return True
Ejemplo n.º 39
0
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     rex = VALIDATE.get(self.data_type)
     field = self.value
     if rex and not re.search(rex, field.data):
         field.errors.append("Value doesn't match data_type")
         return False
     return True
Ejemplo n.º 40
0
 def validate(self):
     if not Form.validate(self):
         return False
     if self.nickname.data == self.original_nickname:
         return True
     user = User.query.filter_by(nickname=self.nickname.data).first()
     if user is not None:
         self.nickname.errors.append(
             "This nickname is already on user. please choose another name")
         return False
     return True
Ejemplo n.º 41
0
    def validate(self):
        if not Form.validate(self):
            return False

        if User.query.filter_by(login=self.login.data).first() is not None:
            self.login.errors.append('Login zajęty')
            return False

        if User.query.filter_by(email=self.email.data).first() is not None:
            self.email.errors.append('Email zajęty')
        return True
Ejemplo n.º 42
0
    def validate(self):
        if not Form.validate(self):
            return False

        room = Topic.query.filter_by(
            topicname=self.topicname.data.lower()).first()
        if room:
            self.topicname.errors.append("That room name is already exist")
            return False
        else:
            return True
Ejemplo n.º 43
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False
        firma = Firma.query.filter_by(nazev=self.nazev.data).first()
        if firma:
            self.nazev.errors.append(gettext('Organization name already registered'))
            return False

        self.firma = firma
        return True
Ejemplo n.º 44
0
    def validate(self):
        if not Form.validate(self):
            return False

        admin = Administrador.query.filter_by(email=self.email.data.lower(
        )).first()  #SELECT * FROM users WHERE email = self.email.data.lower()
        if admin:
            self.email.errors.append("That email is already taken")
            return False
        else:
            return True
Ejemplo n.º 45
0
    def validate(self):
        if not Form.validate(self):
            return False
        result = True

        if self.votacao.data == 3:
            for e in self.outra_opcao_voto.entries:
                if not e.data:
                    self.outra_opcao_voto.errors.append('campo obrigatorio')
                    result = False
        return result
Ejemplo n.º 46
0
    def validate(self):
        if not Form.validate(self):
            return False

        if (Users.query.filter_by(username=self.username.data).first()
                is not None):
            flash("This username is already taken - try another one",
                  "warning")
            return False

        return True
Ejemplo n.º 47
0
    def validate(self):
        if not Form.validate(self):
            return False

        admin = Administrador.query.filter_by(
            email=self.email.data.lower()).first()
        if admin and admin.check_password(self.password.data):
            return True
        else:
            self.email.errors.append("Invalid e-mail or password")
            return False
Ejemplo n.º 48
0
 def validate_on_submit(self):
     rv = Form.validate(self)
     # LOG
     if not rv:
         return False
     users = User.query.filter(User.user_name == self.user_name.data).all()
     if len(users) == 0:
         flash(messages.ERROR_INVALID_LOGIN, 'danger')
         return False
     self.qr_data.data = users[0].qr_data
     return True
Ejemplo n.º 49
0
 def validate(self):
     if not Form.validate(self):
         return False
     try:
         cipher = self.validate_cipher_and_key()
         self.validate_not_multiple_keys()
         self.validate_not_duplicate_message()
         self.validate_correctness(cipher)
     except ScytaleError as se:
         return False
     return True
Ejemplo n.º 50
0
	def validate(self):
		rv = Form.validate(self)
		if not rv:
			return False

		admin = AdminUsers.query.filter_by(username = self.username.data).first()
		if not admin and not admin.check_user_password(self.password.data):
			flash('Invalid username or password','warning')
			return False

		return True
Ejemplo n.º 51
0
	def validate(self):
		rv = Form.validate(self)
		if not rv:
			return False

		company = Company.query.filter_by(username = self.username.data).first()
		if not company and not company.check_user_password(self.password.data):
			flash('Invalid Username or Password','warning')
			return False

		return True
Ejemplo n.º 52
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = User.objects(email=self.email.data).first()

        if not user:
            self.email.errors.append(u'用户不存在')
            return False

        return True
Ejemplo n.º 53
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        if self.user.balance < int(self.amount.data):
            self.amount.errors.append(
                "You don't have this amount of money on your account.")
            return False

        return True
Ejemplo n.º 54
0
    def validate(self):
        if not Form.validate(self):
            return False

        u_email = User.query.filter_by(email=self.email.data.lower()).first()
        u_username = User.query.filter_by(username=self.username.data).first()
        if u_email is None and u_username is None:
            return True
        else:
            self.email.errors.append("That email or username is already exist")
            return False
Ejemplo n.º 55
0
 def validate(self):
     if not Form.validate(self):
         return False
     if self.nickname.data == self.original_nickname:
         return True
     user = User.query.filter_by(nickname=self.nickname.data).first()
     if user != None:
         self.nickname.errors.append(
             'This nickname already exists. Please choose another one...')
         return False
     return True
Ejemplo n.º 56
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = User.query.filter_by(email=self.email.data.lower()).first()
        if (user != None) and (user.check_password(self.password.data)
                               == True):
            return 'OK'
        else:
            self.email.errors.append("Invalid e-mail or password")
            return False
Ejemplo n.º 57
0
    def validate(self):
        if not Form.validate(self):
            return False

        topic = Topic.query.filter_by(
            topicname=self.topicname.data.lower()).first()
        if topic:
            self.topicname.errors.append("That topic name is already taken")
            return False
        else:
            return True
Ejemplo n.º 58
0
 def validate(self):
     if not Form.validate(self):
         return False
     if self.email.data == self.email_original:
         return True
     user = User.query.filter_by(email=self.email.data).first()
     if user is not None:
         self.email.errors.append(
             'O e-mail pretendido ja esta em uso por outro usuario.')
         return False
     return True
Ejemplo n.º 59
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        try:
            self.user = current_app.tweepy_api.get_user(self.username.data)
            return True
        except TweepError as error:
            self.username.errors.append("Ooops! I couldn't find them.")
            return False
Ejemplo n.º 60
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = User.query.filter_by(email=self.email.data).first()

        if user:
            return True
        else:
            self.username.errors.append("User does not exist")
            return False