Esempio n. 1
0
	def delete(self, id):
		_user = User.delete(id, db)
		if _user != "":
			result = True
		else:
			result = False

		return result, date_time_today(), 'delete()'
Esempio n. 2
0
	def get(self, id):
		_user = User.get(id)
		if _user != "":
			result = True
		else:
			result = False

		return result, date_time_today(), 'get()'
Esempio n. 3
0
	def get_all(self):
		_users = User.get_all()
		if _users != []:
			result = True
		else:
			result = False
		
		return result, date_time_today(), 'get_all()'
Esempio n. 4
0
def authenticate():
    user = User()
    _user = user.user_by_usercpf(
        request.form['usercpf'])  # Caso encontre o usuário, retorna

    # Caso o usuáro seja encontrado
    if _user != None:
        resultPassaword = user.check_password(request.form['password'],
                                              _user.password_hash)
        # Caso o usuáro seja encontrado
        if resultPassaword:
            login_user(_user)

            return redirect(url_for('index'))
        else:
            return redirect(url_for('login'))
    else:
        return redirect(url_for('login'))
Esempio n. 5
0
	def insert_2(self):
		data = {'username': '******', 'usercpf': '222.222.222-22',
					'email': '[email protected] ', 'password_hash': self.password_hash}

		_user = User.insert(data, db)

		if _user != "":
			result = True
		else:
			result = False

		return result, date_time_today(), 'insert_user_2()'
Esempio n. 6
0
	def insert(self):
		data = {'username': self.username, 'usercpf': self.usercpf,
					'email': self.email, 'password_hash': self.password_hash}

		_user = User.insert(data, db)

		if _user != "":
			result = True
		else:
			result = False

		return result, date_time_today(), 'insert()'
Esempio n. 7
0
def insert_db(file, fileExtension):
    dataFile = {
        'name': os.path.splitext(file.filename)[0],
        'path': file.filename,
        'insertion_date': datetime.now(),
        'size': get_size(file),
        'extension': fileExtension,
        'expiration_date': datetime.now(),
        '_bucket': Bucket.get_for_name(name=current_user.bucket[0].name),
        '_user': User.get(id=current_user.id)
    }

    _file = File().insert(data=dataFile, db=db)

    if _file:
        return True

    return False
Esempio n. 8
0
def load_user(id):
    return User().user_by_id(id)
Esempio n. 9
0
dicResult = {} #Cria um dicionário que irá conter todos os resultados dos testes
listResult = []

#Teste com User
_userTest = UserTest()
listResult.append(_userTest.insert())
listResult.append(_userTest.insert_2())
listResult.append(_userTest.get_all())
listResult.append(_userTest.get(id=1))

dicResult['User'] = listResult
listResult = []

#Teste com Bucket
_bucketTeste = BucketTest()
listResult.append(_bucketTeste.insert(_user=User.get(1)))
listResult.append(_bucketTeste.insert(_user=User.get(2)))
listResult.append(_bucketTeste.get_all())
listResult.append(_bucketTeste.get(id=1))

dicResult['Bucket'] = listResult
listResult = []

#Teste com File
_fileTest = FileTest()
listResult.append(_fileTest.insert('txt', _user=User.get(1),
								   _bucket=Bucket.get_for_name(User.get(1).usercpf)))
listResult.append(_fileTest.get_all())
listResult.append(_fileTest.get(id=1))

dicResult['File'] = listResult