示例#1
0
 def update(_id, bill_type, employee_id, manager_id, department_id,
            date_of_submission, bill_image_url, status):
     response = {}
     response['bill_type'] = bill_type
     if employee_id is None:
         response['manager_id'] = manager_id
     else:
         response['employee_id'] = employee_id
     response['department_id'] = department_id
     response['date_of_submission'] = date_of_submission
     response['bill_image_url'] = bill_image_url
     response['status'] = status
     Database.update(billConstant.COLLECTION, {'_id': _id}, response)
示例#2
0
 def setUp(self):
     self.stuart_twitter_access_token = "GTvMXibcnUYoMDnD2MTaRD5xp"
     self.stuart_twitter_access_secret = "16DaykgV8kMWGr5WOBhUd0u1l4cpVvfP7ttnY9Qu2XC4trFZkJ"
     self.app_context = app.app_context()
     with self.app_context:
         g.database = Database(
             'mongodb://*****:*****@ds063879.mongolab.com:63879/heroku_app34205970'
         )
示例#3
0
    def register(company_name, ceo, email, password, contact, gst_no):
        # """
        # registers the company for bill reimbursement
        # :raises: company already registered, admin already registered
        # :return: true if successfully registered
        # """
        company_data = Database.find_one(adminConstant.COLLECTION, {"company_name":company_name})
        admin_data = Database.find_one(adminConstant.COLLECTION, {"email": email})

        if company_data is not None:
            raise adminErrors.CompanyAlreadyRegisteredError("Your company is already registered")
        if admin_data is not None:
            raise adminErrors.AdminAlreadyRegisteredError("You are already registered")
        if not Utils.email_is_valid(email):
            raise adminErrors.InvalidEmailError("You entered wrong email")
        Admin(company_name, ceo, email, Utils.hash_password(password), contact, gst_no).save_to_db()

        return True
示例#4
0
    def __init__(self, database: Database, object, dry = False, erase_missing = False):
        ws = database.workspaces()[object.workspace] if isinstance(object, Project) else object
        config = database.config

        self.dry = dry
        self.path = join(object.path, object.name)
        self.remotePath = ws.host + ':' + join(ws.src, object.name)
        self.exclude = self._getExcludeFile(object.path, object.name, config)
        self.backend = RsyncSync(config.argSync, self.exclude, self.dry, erase_missing)
        self.options = self.backend.options()
 def get_by_employee_id(cls, _id):
     print("Emp id:",_id)
     # given the employee's ID and returns the particular employee's details
     # return cls(**Database.find_one(employeeConstants.COLLECTION,{'_id':_id}))
     response = Database.find_one(employeeConstants.COLLECTION, {'_id': _id})
     print("he is mad", response)
     if response is None:
         return None
         # raise EmployeeError.EmployeeNotExistError
     else:
         print(cls(**response))
         return cls(**response)
    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: employee's data
        # """
        employee_data = Database.find_one(employeeConstants.COLLECTION, {'email':email})
        print(employee_data['password'])
        if not Utils.check_hashed_password(old_password, employee_data['password']):
            raise EmployeeError.IncorrectPasswordError("Password does not match")

        return cls(**employee_data)
示例#7
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: admins's data
        # """
        admin_data = Database.find_one(adminConstant.COLLECTION, {'email': email})
        #print(manager_data['password'])
        if not Utils.check_hashed_password(old_password, admin_data['password']):
            raise adminErrors.IncorrectPasswordError("Password does not match")

        return cls(**admin_data)
    def is_login_valid(email, password):
        # """
        # checks if the entered credentials exist in database
        # :param email: user entered
        # :param password: user entered
        # :raises: Employee not exist, incorrect password exception
        # :return: True
        # """
        employee_data = Database.find_one(employeeConstants.COLLECTION, {'email': email})

        if employee_data is None:
            raise EmployeeError.EmployeeNotExistError("You are not registered yet!")
        if not Utils.check_hashed_password(password, employee_data['password']):
            raise EmployeeError.IncorrectPasswordError("You entered wrong password!")
        return True
示例#9
0
    def is_login_valid(email, password):
        # """
        # Checks if the entered credentials exist in database
        # :param email: user entered
        # :param password: user entered
        # :raises: Admin not exist, incorrect password exception
        # :return: True
        # """
        admin_data = Database.find_one(adminConstant.COLLECTION, {"email":email})

        if admin_data is None:
            raise adminErrors.AdminNotExistsError("You are not registered")
        if not Utils.check_hashed_password(password, admin_data['password']):
            raise adminErrors.IncorrectPasswordError("Your password is wrong")

        return True
 def get_by_id(cls, _id):
     # get particular department
     return Database.find_one(departmentConstant.COLLECTION, {"_id": _id})
 def save_to_db(self):
     # to save data to the manager's database
     Database.insert(departmentConstant.COLLECTION, self.json())
示例#12
0
def init_db():
    g.database = Database(mongodb_uri)
示例#13
0
 def update_to_db(self):
     # update bill-type details
     Database.update(billTypeConstant.COLLECTION, {'_id': self._id},
                     self.json())
示例#14
0
 def get_by_id_for_manager(_id):
     return Database.find_one(billConstant.COLLECTION, {'_id': _id})
示例#15
0
 def get_by_id(cls, _id):
     return cls(**Database.find_one(billConstant.COLLECTION, {'_id': _id}))
示例#16
0
 def delete(cls, bill_id):
     Database.delete(billConstant.COLLECTION, {'_id': bill_id})
示例#17
0
 def save_to_db(self):
     if self.employee_id is not None:
         Database.insert(billConstant.COLLECTION, self.employee_json())
     else:
         Database.insert(billConstant.COLLECTION, self.manager_json())
示例#18
0
 def manager_update_to_db(self):
     print(self.manager_json())
     Database.update(billConstant.COLLECTION, {'_id': self._id},
                     self.manager_json())
 def get_all(cls, company_id):
     # get all departments of the company
     departments = Database.find(departmentConstant.COLLECTION,
                                 {'company_id': company_id})
     return departments
 def all(cls, company_id):
     return [
         cls(**elem) for elem in Database.find(
             departmentConstant.COLLECTION, {"company_id": company_id})
     ]
示例#21
0
 def get_by_id(cls, _id):
     # get particular bill-type
     return cls(
         **Database.find_one(billTypeConstant.COLLECTION, {"_id": _id}))
示例#22
0
#!/usr/local/bin/python3.7 -u
from platform.utils.main import main, ConfigHooks
from src.db.database import Database, initconfig
from src.db.settings import validatefiles, createfiles

if __name__ == '__main__':
    hooks = ConfigHooks(checkfiles=validatefiles,
                        createfiles=createfiles,
                        saveconfig=initconfig,
                        createdatabase=lambda: Database())
    main('rs',
         ['{path} - программа для синхронизации кода и удалённой сборки'],
         hooks)
示例#23
0
 def all_bills_type_by_department_id(cls, department_id):
     # get all bill-types of particular department
     billtypes = Database.find(billTypeConstant.COLLECTION,
                               {'department_id': department_id})
     return billtypes
示例#24
0
 def save_to_db(self):
     # to save data to the bill-type's database
     Database.insert(billTypeConstant.COLLECTION, self.json())
示例#25
0
 def all_bills(cls, department_id, status):
     return Database.find(billConstant.COLLECTION, {
         'department_id': department_id,
         'status': status
     })
示例#26
0
 def delete(self):
     # delete a bill-type
     Database.delete(billTypeConstant.COLLECTION, {'_id': self._id})
示例#27
0
 def setUp(self):
     self.app_context = app.app_context()
     with self.app_context:
         g.database = Database(app.mongolab_uri)
示例#28
0
 def all(cls, department_id):
     # get all bill-types from department
     return [
         cls(**elem) for elem in Database.find(
             billTypeConstant.COLLECTION, {'department_id': department_id})
     ]
示例#29
0
 def setUp(self):
     self.database = Database(
         'mongodb://*****:*****@ds063879.mongolab.com:63879/heroku_app34205970'
     )
示例#30
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
     })
示例#31
0
def db_initialize():
    print("created")
    Database.initialize()