Ejemplo n.º 1
0
    def is_reset_password_valid(cls, email, old_password):
        # """
        # It checks whether the credentials are valid and exist
        # :param email: user email
        # :param old_password: user entered
        # :raise: Incorrect password exception
        # :return: manager's data
        # """
        manager_data = Database.find_one(managerConstants.COLLECTION,
                                         {'email': email})
        print(manager_data['password'])
        if not Utils.check_hashed_password(old_password,
                                           manager_data['password']):
            raise ManagerError.IncorrectPasswordError(
                "Password does not match")

        return cls(**manager_data)
Ejemplo n.º 2
0
    def is_login_valid(email, password):
        # """
        # checks if the entered credentials exist in database
        # :param email: user entered
        # :param password: user entered
        # :raises: Manager not exist, incorrect password exception
        # :return: True
        # """

        manager_data = Database.find_one(managerConstants.COLLECTION,
                                         {"email": email})

        if manager_data is None:
            raise ManagerError.ManagerNotExistError(
                "You are not registered yet!")
        if not Utils.check_hashed_password(password, manager_data['password']):
            raise ManagerError.IncorrectPasswordError(
                "You entered wrong password!")
        return True
Ejemplo n.º 3
0
 def get_amount(department_id, type):
     # get amount reimburse for the bill type of a department
     return Database.find_one(billTypeConstant.COLLECTION, {
         'department_id': department_id,
         'type': type
     })
Ejemplo n.º 4
0
 def get_by_id(cls, _id):
     # get particular bill-type
     return cls(
         **Database.find_one(billTypeConstant.COLLECTION, {"_id": _id}))
Ejemplo n.º 5
0
 def get_by_id(cls, _id):
     # get particular department
     return Database.find_one(departmentConstant.COLLECTION, {"_id": _id})
Ejemplo n.º 6
0
 def get_by_id_for_manager(_id):
     return Database.find_one(billConstant.COLLECTION, {'_id': _id})
Ejemplo n.º 7
0
 def get_by_id(cls, _id):
     return cls(**Database.find_one(billConstant.COLLECTION, {'_id': _id}))
Ejemplo n.º 8
0
 def get_by_employee_email(cls, email):
     # to get employees from manager's email
     employee = Database.find_one(employeeConstants.COLLECTION, {'email': email})
     # print(employee)
     return employee
Ejemplo n.º 9
0
 def get_by_email(cls, email):
     # to get company ID using admin's email
     company_id = Database.find_one(adminConstant.COLLECTION, {'email':email})['_id']
     return company_id
Ejemplo n.º 10
0
 def get_by_manager_id(cls, _id):
     # given the manager's ID and returns the particular manager's details
     return cls(
         **Database.find_one(managerConstants.COLLECTION, {'_id': _id}))