예제 #1
0
    def validate(self):
        outcome = True

        rv = Form.validate(self)
        if not rv:
            outcome = False

        if self.label.data == '':
            self.label.errors.append('Campo obbligatorio')
            outcome = False

        if self.x.data == '':
            self.x.errors.append('Campo obbligatorio')
            outcome = False
        else:
            try:
                float(self.x.data) if '.' in self.x.data else int(self.x.data)
            except ValueError:
                self.x.errors.append('Valore immesso non valido')
                outcome = False

        if self.y.data == '':
            self.y.errors.append('Campo obbligatorio')
            outcome = False
        else:
            try:
                float(self.y.data) if '.' in self.y.data else int(self.y.data)
            except ValueError:
                self.y.errors.append('Valore immesso non valido')
                outcome = False

        return outcome
예제 #2
0
    def validate(self):
        if not Form.validate(self):
            return False

        errorcheck = False
        onepass = False
        while not onepass and not errorcheck:
            user = User.query.filter_by(nickname=self.nickname.data).first()
            if user != None:
                self.nickname.errors.append(
                    'This nickname is already in use. Please choose another one.'
                )
                errorcheck = True

            robot = Robot.query.filter_by(alias=self.robot_name.data).first()
            if robot != None:
                self.robot_name.errors.append(
                    'This robot name is already in use. Please choose another one.'
                )
                errorcheck = True

            mac = Robot.query.filter_by(macid=self.robot_mac.data).first()
            if mac != None:
                self.robot_mac.errors.append(
                    'This robot already has an owner.')
                errorcheck = True
            onepass = True

        if errorcheck:
            return False

        return True
예제 #3
0
    def validate(self):
        rv = Form.validate(self)
        self.rv = rv

        usernameExists = User.query.filter(
            User.username == self.reg_username.data).count() != 0
        self.usernameExists = usernameExists
        if usernameExists:
            self.reg_username.errors.append(
                'The username you have selected is already in use')
            return False

        emailExists = User.query.filter(
            User.email == self.reg_email.data).count() != 0
        self.emailExists = emailExists
        if emailExists:
            self.reg_email.errors.append(
                'The email address you have selected is already in use!'
            )  #perhaps we should let users make multiple accounts?
            return False
        if self.rv:
            self.user = User(self.reg_email.data,
                             self.reg_username.data,
                             plainTextPassword=self.reg_password.data)
            db.session.add(self.user)
            db.session.commit()
        return self.rv
예제 #4
0
파일: forms.py 프로젝트: Lan-Yang/WeDeliver
    def validate(self):
        ''' validate the form '''
        rv = Form.validate(self)
        if not rv:
            return False

        if self.who.data == "shipper":
            user = Shipper.query.filter_by(
                email=self.email.data
                ).first()
            if user is None:
                self.email.errors.append(u"This email not registered")
                return False
            if not check_password_hash(
                user.passwd,
                self.passwd.data
                ):
                self.passwd.errors.append(u"Username and password don't match")
                return False
        else:
            user = Deliverer.query.filter_by(
                email=self.email.data
                ).first()
            if user is None:
                self.email.errors.append(u"This email not registered")
                return False
            if not check_password_hash(
                user.passwd,
                self.passwd.data
                ):
                self.passwd.errors.append(u"Username and password don't match")
                return False

        self.user = user
        return True
예제 #5
0
    def validate(self, regCode):
        rv = Form.validate(self)
        if not rv:
           return False

        # check if user has given valid lol id
        summonerid = self.bslol.getSummonerId(self.summonername.data)
        if summonerid == None:
            self.summonername.errors.append("You've entered and invalid summoner id")
            return False

        # check if user has givne a valid twitter id

        # FIX: we must send reg_code to the dm
        twtRetCode = self.bstwt.sendDM(self.twtid.data, regCode)
        if twtRetCode != 0:
            if twtRetCode == 34: # error code 34: twitter user does not exist
                self.twtid.errors.append("You've entered an invalid Twitter ID!")
                return False
            elif twtRetCode == 150: # error code 150: not following us
                self.twtid.errors.append('To verify your Twitter account, we need to send you a direct message. Follow @bsbot_lol now!')
                return False
            else:
                self.twtid.errors.append('Error connecting to Twitter :(')
                return False

        return True
예제 #6
0
파일: forms.py 프로젝트: 5p2p/talkatv
    def validate(self):
        if not Form.validate(self):
            return False

        user_exists = User.query.filter(
                User.username==self.username.data).filter(
                        User.email!=g.user.email).count()

        if user_exists:
            self.username.errors.append(
                    'The username "{0}" is already taken'.format(
                        self.username.data))
            return False

        email_exists = User.query.filter(
                User.email==self.email.data).filter(
                        User.username!=g.user.username).count()

        if email_exists:
            self.email.errors.append(
                    'The email "{0}" is already taken'.format(
                        self.email.data))
            return False

        return True
예제 #7
0
    def validate(self):
        rv = Form.validate(self)
        self.rv = rv
        if not rv:
            return False

        self.artwork = Artwork(current_user.id,
                               self.title.data,
                               self.cost.data,
                               styleId=self.style.data,
                               supportTypeId=self.support_type.data,
                               typeId=self.type.data,
                               height=self.height.data,
                               width=self.width.data,
                               mediumId=self.medium.data,
                               framed=self.framed.data,
                               description=self.description.data)

        self.artwork.is_reviewd = app.config['DEBUG']

        try:
            db.session.add(self.artwork)
            db.session.commit()
        except IntegrityError as e:
            db.session.rollback()
            app.logger.debug(e)
            return False

        return True
예제 #8
0
    def validate(self):
        self.rv = Form.validate(self)
        if not self.rv:
            return False
        tUser = User.getByUsername(self.login_username.data)
        if tUser == None:  #not a valid username
            tUser = User.getByEmail(
                self.login_username.data
            )  #check if it is actaully an email address
            if tUser == None:
                self.login_username.errors.append(
                    "The username you have entered does not exist")
                return False
            if tUser.is_oauth_user:
                self.login_username.errors.append(
                    "The email you have entered is associated with a Facebook account, please login using Facebook."
                )

        if not tUser.validatePassword(self.login_password.data):
            self.login_password.errors.append(
                "It seems you have entered an incorrect password")
            return False

        self.user = tUser
        return True
예제 #9
0
파일: forms.py 프로젝트: TZilla/HydroPi
    def validate(self):
        
        if not Form.validate(self):
            return False
        valid=True #assume success
        email = mongo.db.users.find({'email':self.email.data.lower()}).count()
        username = mongo.db.users.find({'username':self.username.data.lower()}).count()

        if email>0:
            self.email.errors.append("That email is already taken")
            valid=False
        if username>0:
            self.username.errors.append("That username is already taken")
            valid=False
        if(len(self.password.data)<8):
            self.password.errors.append("Passwords must be at least 8 characters long")
            self.password1.errors.append("")
            valid=False
        else:
            self.salt = uuid.uuid4().bytes
            self.password.data = hashlib.sha512(self.password.data.encode('utf-8') + self.salt).digest()
            self.password1.data = hashlib.sha512(self.password1.data.encode('utf-8') + self.salt).digest()
        if(self.password.data!=self.password1.data):
            self.password.errors.append("The passwords do not match")
            self.password1.errors.append("")
            valid=False
        return valid
예제 #10
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            print 'not OK'
            return False

        return True
예제 #11
0
파일: forms.py 프로젝트: yifanwu/hcfsite
 def validate(self):
     if not Form.validate(self):
         return False
     if self.name == None:
         self.name.errors.append("This is an invalid entry!")
         return False
     return True
예제 #12
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            print 'not OK'
            return False

        return True
예제 #13
0
파일: loginForm.py 프로젝트: golgoth/Webito
	def validate(self):
		"""
		Validaion of the form, checking user password hash with stored one.
		:return: True if the form is correct and the user as given correct credentials, 
		False otherwise
		"""
		cust_logger.info("Trying to validate form")

		rv = Form.validate(self)
		if not rv:
			return False

		user = User.objects(username=self.username.data.lower()).first()
		if user is None:
			cust_logger.info("Invalid username entered")
			self.password.errors.append('Unknown username or password')
			return False

		if not user.check_password(self.password.data):
			cust_logger.info("Invalid password entered")
			self.password.errors.append('Unknown username or password')
			return False

		self.user = user
		return True
예제 #14
0
    def validate(self):
        if not Form.validate(self):
            return False

        if self.username.data == 'admin' and self.password.data == 'qwer1234':
            return True

        print self.username.data
        cursor = get_db().execute("SELECT * from USERS where USERNAME = ?;", [self.username.data])
        cnt = cursor.fetchone()
        print cnt
        if cnt is None:
            return False
        userrow = make_dict(cursor, cnt)
        if userrow is None:
            #self.username.errors.append('Unknown username')
            return False

        if get_db().execute("SELECT CLASS from GPA where SID = ?;", [userrow['USERNAME']]).fetchone()[0][2] == u'2':
            ''' 二字班的同学说不要看到成绩 '''
            return False

        if self.password.data != userrow['PASSWORD']:
            #self.password.errors.append('Invalid password')
            return False

        self.user = User(username=userrow['USERNAME'], password=userrow['PASSWORD'], choice=userrow['CHOICE'])
        return True
예제 #15
0
파일: forms.py 프로젝트: yifanwu/hcfsite
 def validate(self):
     if not Form.validate(self):
         return False
     if self.passphrase.data != "hcf2013admin":
         self.passphrase.errors.append("Invalid pass phrase, only HCF board members have access.")
         return False
     return True
예제 #16
0
파일: forms.py 프로젝트: Warprobot/diplom
 def validate(self):
     if not Form.validate(self):
         return False
     if User.query.filter_by(email=self.email.data).first() is not None:
         raise ValidationError(u'Пользователь с таким email адресом уже существует!')
     else:
         return True
예제 #17
0
파일: forms.py 프로젝트: kglazko/ship-it
    def validate(self, release, *args, **kwargs):
        valid = Form.validate(self, *args, **kwargs)
        # Completed releases shouldn't be altered in terms of readyness or
        # completeness. Status updates are OK though.
        if release.complete:
            if self.ready.data is False or self.complete.data is False:
                valid = False
                if 'ready' not in self.errors:
                    self.errors['ready'] = []
                self.errors['ready'].append('Cannot make a completed release not ready or incomplete.')

            # Check if there is an other product-version already shipped
            similar = getReleases(status="postrelease", productFilter=release.product,
                                  versionFilter=release.version)
            if similar and self.status.data != "Started":
                # In most of the cases, it is useless since bug 1121032 has been implemented but keeping it
                # in case we change/revert in the future and because we cannot always trust the client
                valid = False
                if 'postrelease' not in self.errors:
                    self.errors['postrelease'] = []
                self.errors['postrelease'].append('Version ' + release.version + ' already marked as shipped')

        # If the release isn't complete, we can accept changes to readyness or
        # completeness, but marking a release as not ready *and* complete at
        # the same time is invalid.
        else:
            if self.ready.data is False and self.complete.data is True:
                valid = False
                if 'ready' not in self.errors:
                    self.errors['ready'] = []
                self.errors['ready'].append('A release cannot be made ready and complete at the same time')

        return valid
예제 #18
0
파일: forms.py 프로젝트: brad-lucas/Arivale
    def validate(self):
        if not Form.validate(self):
            return False

        customer = self.getClass().query.filter_by(email=self.email.data.lower()).first()

        return self.performValidate(customer)
예제 #19
0
파일: forms.py 프로젝트: Red54/Sophia
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     current_time = int(time.time())
     if self.team_id.data:
         team = Team.query.get(self.team_id.data)
     else:
         team = Team()
     team.admin_id = self.admin_user.id
     team.name = self.name.data
     team.created_at = current_time
     if self.status.data:
         team.status = 1
     else:
         team.status = 0
     db.session.add(team)
     db.session.commit()
     if not self.team_id.data:
         team_user = TeamUser()
         team_user.team_id = team.id
         team_user.user_id = self.admin_user.id
         db.session.add(team_user)
         db.session.commit()
     if self.status.data:
         team_user = TeamUser.query.filter(db.and_(TeamUser.team_id == team.id and
                                                   TeamUser.user_id == self.admin_user.id)).first()
         if team_user:
             db.session.delete(team_user)
             db.session.commit()
         db.session.query(Project).filter(Project.team_id == team.id).update({Project.status: 1})
         db.session.commit()
     self.team = team
     return True
예제 #20
0
파일: forms.py 프로젝트: Red54/Sophia
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     if not self.project:
         self.project = Project()
     if not self.user:
         self.name.errors.append(u'没有指定用户')
         return False
     if not self.team_id.data and self._team:
         team_id = self._team.id
     else:
         team_id = self.team_id.data
     self.project.name = self.name.data
     self.project.subject = self.subject.data
     self.project.creator_id = self.user.id
     self.project.created_at = int(time.time())
     self.project.team_id = team_id
     self.project.todo_count = 0
     self.project.file_count = 0
     self.project.topic_count = 0
     self.project.status = 0
     db.session.add(self.project)
     db.session.commit()
     return True
예제 #21
0
파일: forms.py 프로젝트: Red54/Sophia
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     if self.new_password.data:
         if not self.current_password.data:
             self.current_password.errors.append(u'请填写现有密码')
             return False
         if not self.user.check_password(self.current_password.data):
             self.current_password.errors.append(u'密码填错了亲')
             return False
         self.user.password = self.user.hash_password(self.new_password.data)
     self.user.email = self.email.data
     self.user.name = self.name.data
     self.user.updated_at = int(time.time())
     old_file = None
     if self.avatar.data:
         old_file = self.user.avatar
         self.user.avatar = u"%s" % self.avatar.data.filename
     db.session.add(self.user)
     db.session.commit()
     if old_file and old_file != 'default_avatar.jpg':
         old_file = os.path.join(AVATAR_FOLDER, old_file)
         if os.path.exists(old_file):
             os.remove(old_file)
     return True
예제 #22
0
 def validate(self):
     rv = Form.validate(self)
     username = self.username.data
     password = self.password.data
     
     if not rv:
         # invalid information
         self.username.errors.append('Something gone wrong')
         return False
     
     if not User.check_username(username):
         # user does NOT exist
         self.username.errors.append('Invalid username and/or password')
         return False
     
     if not User.check_password(username, password):
         # incorrect password
         self.password.errors.append('Invalid username and/or password')
         return False
     
     user = User(username=username)
     
     if user is None:
         # user could not create for some reason
         self.username.errors.append('Invalid username and/or password')
         return False
     
     self.user = user
     return True
예제 #23
0
	def validate(self):
		if not Form.validate(self):
			return False

		errorcheck = False
		onepass = False
		while not onepass and not errorcheck:
			user = User.query.filter_by(nickname=self.nickname.data).first()
			if user != None:
				self.nickname.errors.append('This nickname is already in use. Please choose another one.')
				errorcheck = True

			robot = Robot.query.filter_by(alias=self.robot_name.data).first()
			if robot != None:
				self.robot_name.errors.append('This robot name is already in use. Please choose another one.')
				errorcheck = True

			mac = Robot.query.filter_by(macid=self.robot_mac.data).first()
			if mac != None:
				self.robot_mac.errors.append('This robot already has an owner.')
				errorcheck = True
			onepass = True
		
		if errorcheck:
			return False

		return True
예제 #24
0
파일: authform.py 프로젝트: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: A User object representing the found user, or None
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

         #  We need to find a user's id by their email address.
        user = User.get_user_from_email(self.email.data)

        if user is None:
            self.email.errors.append('Unknown Email Address')
            flash('Unknown Email Address', 'error')
            return False

        if not user.check_password(self.password.data):
            self.password.errors.append('Invalid password')
            flash('Invalid password', 'error')
            return False

        self.user = user
        return True
예제 #25
0
파일: authform.py 프로젝트: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: A User object representing the found user, or None
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

        identity = OTP(self.yubi_input.data).device_id

         #  We need to find a user's id by their Yubico Token ID.
        user = User.get_user_from_yubitoken(identity)

        if user is None:
            self.yubi_input.errors.append('Unknown Identity')
            flash('Unknown Identity', 'error')
            return False

        if not user.check_yubitoken(self.yubi_input.data):
            self.yubi_input.errors.append('Invalid Token')
            flash('Invalid Token', 'error')
            return False

        self.user = user
        return True
예제 #26
0
파일: authform.py 프로젝트: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: True if the User object was successfully created, or False if it was not.
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

         #  We need to find a user's id by their email address.
        user = User.get_user_from_email(self.email.data)

        if user is not None:
            self.email.errors.append('Email Address Exists')
            flash('Email Address Exists', 'error')
            return False

        user = User.make(self.email.data, self.password.data)

        if user is not None:
            self.user = user
            return True
        else:
            return False
예제 #27
0
파일: authform.py 프로젝트: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: True if the password can be changed, or False if the operation should not continue.
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

        ## We need to get the user's id from the login session.
        user = current_user  # current_user is a proxy object.
        # We need to assign it to a local to get the reference to the real User object.

        if user is None:  # Then the user doesn't exist.
            flash('Unknown User', 'error')
            return False

        if not user.check_password(self.password.data):
            self.password.errors.append('Invalid old password')
            flash('Invalid old password', 'error')
            return False

        if not self.chkpassword.data == self.newpassword.data:
            self.newpassword.errors.append('New Password pair does not match')
            flash('New Password pair does not match', 'error')
            return False

        return True
예제 #28
0
파일: forms.py 프로젝트: rontom/l0flask
 def validate(self):
     if not Form.validate(self):
         return False
     else:
         u = User.query.get(self.user_id.data)
         email_already_exists = False
         user_with_address = User.query.filter_by(email = self.email.data.lower()).first()
         if user_with_address != None:
             if str(user_with_address.id) != str(self.user_id.data):
                 print(str(user_with_address.id) + " != " + str(self.user_id.data))
                 email_already_exists = True
             
         if len(self.display_name.data) > 50:
             self.display_name.errors.append("max length is 50 characters.")
             return False
         elif email_already_exists:
             self.email.errors.append("email already exists.")
             return False
         else:
             #check password when email has changes
             if u .email != self.email.data:
                 if u.check_password(self.password.data):
                     self.password.errors.append("password must be supplied to update email.")
                     return False
                 else:
                     return True
             else:
                 return True
예제 #29
0
 def validate(self):
     if Form.validate(self):
         user = User.query.filter_by(username=self.username.data.lower()).first()
         print(user)
         if user:
             return user.check_password(self.password.data)
     return False
예제 #30
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        try:
            user = User.objects.get(mcname = self.username.data)
            self.username.errors.append('Minecraft username already registered!')
            return False

        except:
            if self.password.data == self.password_confirm.data:
                self.mcname = self.username.data

                confkey = str(binascii.b2a_hex(os.urandom(16)), "UTF-8")

                if debug:
                    print(confkey)

                addUser("Registered User", self.username.data, is_staff = False, password = self.password.data, email = self.email.data, confkey = confkey)

                sendMail("no-reply", self.email.data, "Confirm Account! - MineZRC Community", "Do jazz hands, click on the link to confirm your account and join the MineZRC community!!:  "+ app.config['SITEURL'] + "/confirm/"+self.mcname+"/"+confkey)


                return True
            else:
                self.password.errors.append("Passwords doesn't match!")
                return False
예제 #31
0
 def validate(self):
     flag_mail = False
     if not Form.validate(self):
         return False
     
     if self.email.data == self.original_mail:
         flag_mail = True
     else:
         user = User.query.filter_by(email=self.email.data).first()
         if user != None:
             self.email.errors.append(u'ce mail est déjà pris !')
             flag_mail = False
         else:
             flag_mail = True
    
     if not flag_mail:
         return False 
     
     if self.new_password.data == '':
         return True
     else:
         # implement some other checks on this new password
         print len(self.new_password.data)
         if len(self.new_password.data) < 8:
             self.new_password.errors.append(u'ton mot de passe doit contenir au moins 8 caractères !')
             return False
         return True
예제 #32
0
 def validate(self):
     if not Form.validate(self):
         return False
     numbersonly = re.sub('[^0-9]', '', self.isbn.data)
     if len(numbersonly) != 10 and len(numbersonly) != 13:
         return False
     return True
예제 #33
0
파일: forms.py 프로젝트: jawrainey/atc
    def validate(self):
        if not Form.validate(self):
            return False

        if not self.forename.data.isalpha():
            self.__reset_field(self.forename,
                               "First name must contain only letters.")

        if not self.surname.data.isalpha():
            self.__reset_field(self.surname,
                               "Last name must contain only letters.")

        try:
            datetime.datetime.strptime(self.dob.data, "%d/%m/%Y")
        except ValueError:
            self.__reset_field(self.dob, "D.O.B format must be DD/MM/YYYY.")

        mobile = self.mobile.data
        if len(mobile) < 7 or len(mobile) > 11:
            self.__reset_field(self.mobile,
                               "Mobile number must between length 7 and 11")

        if mobile[0:2] != '07':
            self.__reset_field(self.mobile, "Mobile number must begin with 07")

        # Validate the UNIQUE mobile number against the DB.
        if models.Patient.query.get(self.mobile.data):
            self.__reset_field(self.mobile,
                               "A patient with that number already exists.")

        if self.forename.errors or self.surname.errors \
                or self.dob.errors or self.mobile.errors:
            return False
        return True
예제 #34
0
 def validate(self):
     if not Form.validate(self):
         return False
         
     result = True
     sum_of_tokens = 0
     ranksArray = []
     num_of_evals = len(self.evaluations)
     
     for field in self.evaluations:
         sum_of_tokens = sum_of_tokens + field['tokens'].data
         ranksArray.append(field['rank'].data)
         is_manager = field['is_manager'].data
         if(is_manager == 1):
             result = self.validateManagerForm(field['managerEval'])            
         
     if sum_of_tokens != 100:
         flash('Sum of Tokens should be 100.')
         result = False
     
     ranksArray.sort()
     if len(ranksArray)!=len(set(ranksArray)):
         flash('Duplicate ranks are NOT allowed.')
         result = False
     if ranksArray[0] != 1 or ranksArray[num_of_evals-1] != num_of_evals:
         flash('Ranks should be assigned from 1 to N.')
         result = False
         
     return result
예제 #35
0
 def validate(self):
   if not Form.validate(self):
     return False
   if self.pass1.data != self.pass2.data:
     self.pass1.errors.append("Please retype your password - they didn't match")
     return False 
   return True
예제 #36
0
파일: forms.py 프로젝트: gshiva/microblog
 def validate(self):
     if not Form.validate(self):
         return False
     if self.name.data == self.original_name:
         return True
     if self.name.data != Node.make_valid_name(self.name.data):
         self.name.errors.append(gettext('This name has invalid characters. Please use letters, numbers, dots and underscores only.'))
         return False
     org = Organization.query.filter_by(name = self.org_name).first()
     if org == None:
         self.name.errors.append(gettext('The organization name was not found'))
         return False
     env = org.envs.filter_by(name = self.env_name).first()
     if env == None:
         self.name.errors.append(gettext('The environment name was not found'))
         return False
     grp = env.groups.filter_by(name = self.grp_name).first()
     if grp == None:
         self.name.errors.append(gettext('The group name was not found'))
         return False
     node = grp.nodes.filter_by(name = self.name.data).first()
     if node != None:
         self.name.errors.append(gettext('The node name already exists'))
         return False
     return True
예제 #37
0
    def validate(self):
        if not Form.validate(self):
            return False

        self.word.data = self.word.data.strip().lower()
        self.translation.data = self.translation.data.strip().lower()

        return True
예제 #38
0
 def validate(self):
     if not self.official_id.data:
         self.official_id.data = self.the_official_id
     if not Form.validate(self):
         print ' + + + Nope'
         return False
     print ' + + + Yup'
     return True
예제 #39
0
파일: form.py 프로젝트: flask-ml/flask-ml
 def validate(self):
     if not Form.validate(self):
         return False
     user = query_user(self.email.data)
     if user != None:
         self.email.errors.append('This email is already in use. Please choose another one.')
         return False
     return True
예제 #40
0
 def validate(self):
     if not Form.validate(self):
         return False
     person = Person.query.filter_by(email=self.email.data.lower()).first()
     if person and person.check_password(self.password.data):
         return True
     else:
         return False
예제 #41
0
파일: forms.py 프로젝트: goodking-bq/zblog
 def validate(self):
     if not Form.validate(self):
         return False
     category = Article.query.filter_by(title=self.title.data).first()
     if category != None:
         self.title.errors.append(u'文章标题不能重复!')
         return False
     return True
예제 #42
0
 def validate(self):
     if not Form.validate(self):
         return False
     if User.query.filter_by(email=self.email.data).first() is None:
         self.email.errors.append("That email does not exist.")
         return False
     else:
         return True
예제 #43
0
 def validate(self):
     if Form.validate(self):
         user = User.query.filter_by(
             username=self.username.data.lower()).first()
         print(user)
         if user:
             return user.check_password(self.password.data)
     return False
예제 #44
0
 def validate(self):
     if not Form.validate(self):
         return False
     user = User.query.filter_by(username=self.username.data).first()
     if user is not None and not user.verify_password(self.password.data):
         self.password.errors.append('Incorrect password.')
         return False
     return True
예제 #45
0
 def validate(self):
     if not Form.validate(self):
         return False
     mentorphoto = Judge.query.filter_by(name=self.name.data).first()
     if mentorphoto:
         return False
     else:
         return True
예제 #46
0
 def validate(self):
     if not Form.validate(self): return False
     user = User.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(u"用户名或密码错误")
         return False
예제 #47
0
파일: forms.py 프로젝트: arvindc95/kaiser
    def validate(self):
        if not Form.validate(self):
            del self.username.errors[:]
            del self.password.errors[:]
            self.username.errors.append("All fields are required.")
            return False

        return True
예제 #48
0
파일: forms.py 프로젝트: vlf1991/poppet-1
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     if self.password and (self.password.data != self.repassword.data):
         self.password.errors.append("Entered passwords didn't match")
         return False
     return True
예제 #49
0
 def validate(self):
     if not Form.validate(self): return False
     user_in_this_name = User.query.filter_by(name=self.name.data).first()
     if user_in_this_name and user_in_this_name.id != g.user.id:
         self.name.errors.append(u"姓名已被使用")
         return False
     else:
         return True
예제 #50
0
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         return False
     if not self.latitude.data or not self.longitude.data:
         self.address.errors.append('Please select a valid address')
         return False
     return True
예제 #51
0
 def validate(self):
     if not Form.validate(self):
         return False
     if User.query.filter(User.email == self.email.data).all():
         self.email.errors.append("User with this email already exists!")
     if User.query.filter(User.nickname == self.nickname.data).all():
         self.nickname.errors.append("User with this nickname already exists!")
     return True
예제 #52
0
 def validation(self):
     validation = Form.validate(self)
     if not validation:
         return False
     elif (validation == 'student' or validation == 'staff'):
         return True
     else:
         return False
예제 #53
0
파일: forms.py 프로젝트: goodking-bq/zblog
 def validate(self):
     if not Form.validate(self):
         return False
     category = Category.query.filter_by(name=self.name.data).first()
     if category != None:
         self.name.errors.append(u'类别名不能重复!')
         return False
     return True
예제 #54
0
 def validate(self):
     if not Form.validate(self):
         return False
     user = User.query.filter_by(email=self.email.data.lower()).first()
     if not user:
         self.email.errors.append(u'이메일이 존재하지 않습니다.')
         return False
     return True
예제 #55
0
파일: forms.py 프로젝트: goodking-bq/zblog
 def validate(self):
     if not Form.validate(self):
         return False
     user = User.query.filter_by(email=self.email.data).first()
     if user != None:
         self.email.errors.append(u'此邮箱已被注册,请直接登录或更换邮箱!')
         return False
     return True
예제 #56
0
 def validate(self):
     if not Form.validate(self):
         return False
     if self.pass1.data != self.pass2.data:
         self.pass1.errors.append(
             "Please retype your password - they didn't match")
         return False
     return True
예제 #57
0
    def validate(self):
        rv = Form.validate(self)
        
        if not rv:
            # invalid information
            return False
        
        # get user account
        username = self.username.data
        
        if not UserAccount.query.filter_by(username=username).count():
            return False
        
        user_account = UserAccount.query.filter_by(username=username).one()
        
        # check password
        if self.current_password.data or self.password.data or self.confirm_password.data:
            if not User.check_password(self.username.data, self.current_password.data):
                # old password did not match
                self.current_password.errors.append('Current password did not match')
                return False

            if self.password.data != self.confirm_password.data:
                # passwords did not match
                self.password.errors.append('Passwords did not match')
                return False
        else:
            self.password.data = user_account.password
        
        # find all field values, and create user
        dct = {}
        
        for k in dir(self.__class__):
            v = getattr(self.__class__, k)
            
            if isinstance(v, (Field, UnboundField)):
                v = getattr(self, k)
                dct[k] = v.data
        
        dct['active'] = True
        print '!!!', dct
        
        try:
            User.update_user(**dct)
        except Exception as e:
            # user could not be created for some reason
            self.username.errors.append('Something gone wrong')
            return False
        
        user = User(username=self.username.data)
        
        if user is None:
            # user could not be created for some reason
            self.username.errors.append('Invalid username')
            return False
        
        self.user = user
        return True
예제 #58
0
 def is_admin(self):
     if not Form.validate(self):
         return False
     user = User.query.filter_by(
         username=self.username.data.lower()).first()
     if user.is_administrator:
         return True
     else:
         return False
예제 #59
0
    def validate(self):
        if not Form.validate(self):
            return False

        if checkEmail(self.email.data.lower()):
            self.email.errors.append("That email is already taken")
            return False
        else:
            return True
예제 #60
0
 def validate(self):
     if not Form.validate(self):
         return False
     user = User.query.filter(User.username.ilike(
         self.username.data)).first()
     if user:
         self.username.errors.append('Username already in use.')
         return False
     return True