예제 #1
0
    def load_books(self):
        self.books = []

        books_data = DC.get_data(self.path)

        for book_from_db_id in books_data:
            new_book = Book.empty()

            new_book.load(self.path + '/' + book_from_db_id)
            new_book.book_ID = book_from_db_id
            self.books.append(new_book)
예제 #2
0
def create_account():

    users_data = DC.get_data(CONSTANTS.USERS_TABLE)

    for user_id in users_data:
        user = User.empty()

        user.load(CONSTANTS.USERS_TABLE + '/' + user_id)
        if user.login == request.form['login']:
            return 'User already exists!'

    user = User(request.form['login'], request.form['password'],
                request.form['name'], request.form['surname'],
                True if request.form['account_type'] == 'true' else False)

    user.save(CONSTANTS.USERS_TABLE)

    return redirect(url_for('login'))
예제 #3
0
    def authenticate(login, password):

        users_data = DC.get_data(CONSTANTS.USERS_TABLE)

        for user_id in users_data:

            user = User.empty()

            user.load(CONSTANTS.USERS_TABLE + '/' + user_id)

            if user.login == login:
                if user.password == password:
                    if user.is_admin:
                        return CONSTANTS.LOGIN_ADMIN
                    else:
                        return CONSTANTS.LOGIN_CLIENT

                else:
                    return CONSTANTS.LOGIN_FAILED

        return CONSTANTS.LOGIN_FAILED
예제 #4
0
 def load(self, path):
     self.__dict__ = DC.get_data(path)