def set_done(bot, name, project, time):
    tm = TaskModel(db.get_connection())
    pm = ProjectModel(db.get_connection())
    um = UserModel(db.get_connection())
    em = EmployeeModel(db.get_connection())

    project_id = pm.get_id(project)
    tid = tm.search(name, project_id)
    boss_id = um.get_boss_id()

    if tid:
        tm.set_done(tid)
        tm.set_done_date(tid)
        tm.set_timer(tid, time)
        task = tm.get(tid)
        bot.sendMessage(boss_id, f'''
<b>Задача выполнена
<u>Исполнитель</u>: {em.get(task[3])[1]}
<u>Проект:</u> {pm.get_name(task[4])}
<u>Задача:</u> {task[1]}
<u>Описание задачи:</u> {task[2]}
<u>Время выполнения:</u> {task[8].split(':')[0]} часа(-ов) {task[8].split(':')[1]} минут
</b>''', parse_mode='HTML')
    else:
        raise TaskNotFound
 def POST(self):
     data = web.input()
     registration = UserModel.UserModel()
     hashed_password = bcrypt.hashpw(data.password.encode(),
                                     bcrypt.gensalt())
     _id = registration.insert_user(data.username, hashed_password,
                                    data.fullname)
     return _id
def add_employee(name, eid):
    um = UserModel(db.get_connection())
    if um.get(eid):
        raise UserAlreadyExist
    else:
        um.insert(eid, name)
        em = EmployeeModel(db.get_connection())
        em.auto_update()
Exemple #4
0
 def post(self):
     args = parser.parse_args()
     goodId = args['goodId'] if 'goodId' in args else None
     styleId = args['styleId'] if 'styleId' in args and args[
         'styleId'] is not None else ""
     quantity = args['quantity'] if 'quantity' in args and args[
         'quantity'] is not None else 1
     access_token = args['access_token'] if 'access_token' in args else None
     response_json = {"isSuccess": False}
     if goodId is not None:
         payload = {}
         if access_token is None:
             payload = {
                 'iss': domain,
                 'sub': uuid.uuid1().int >> 100,
                 'aud': domain,
                 'exp': datetime.utcnow() + timedelta(seconds=3600),
                 'nbf': datetime.utcnow(),
                 'iat': datetime.utcnow(),
                 'jti': uuid.uuid1().int >> 100,
                 'hello': 'world',
             }
             token = jwt.encode(payload, 'secret', algorithm='HS256')
             access_token = token.decode("utf-8")
         else:
             payload = jwt.decode(access_token,
                                  'secret',
                                  audience=domain,
                                  issuer=domain)
         tokenID = str(payload['jti']) if 'jti' in payload else ''
         user = UserModel.query.filter_by(token=tokenID).first()
         if user is not None:
             search = and_(UserBuyModel.token == tokenID,
                           UserBuyModel.goodId == goodId,
                           UserBuyModel.styleId == styleId)
             userbuy = UserBuyModel.query.filter(search).first()
             if userbuy is not None:
                 UserBuyModel.query.filter(search).update({
                     'goodId':
                     goodId,
                     'styleId':
                     styleId,
                     'quantity':
                     quantity
                 })
             else:
                 userDB = UserBuyModel(tokenID, goodId, styleId, quantity)
                 userDB.save_to_db()
         else:
             userDB = UserModel(tokenID, goodId, styleId, quantity)
             userDB.save_to_db()
             userBuyDB = UserBuyModel(tokenID, goodId, styleId, quantity)
             userBuyDB.save_to_db()
         response_json['isSuccess'] = True
         response_json['access_token'] = access_token
     else:
         response_json['message'] = "Don't assign correct product goodId"
     return response_json
Exemple #5
0
 def POST(self):
     data = web.input()
     user_model = UserModel.UserModel()
     valid_user = user_model.check_user(data)
     if valid_user:
         session_data['user'] = valid_user
         return valid_user
     else:
         return 'error'
 def POST(self):
     data = web.input()
     user_model = UserModel.UserModel()
     user = user_model.find_user(data.username)
     if user and bcrypt.checkpw(data.password.encode(), user["password"]):
         session_data["user"] = user
         return user["fullname"]
     else:
         return "error"
def delete_employee(name):
    em = EmployeeModel(db.get_connection())
    uid = em.get_id(name)
    em.delete(uid)

    um = UserModel(db.get_connection())
    um.delete(uid)

    tm = TaskModel(db.get_connection())
    tm.delete_by_emp(uid)
Exemple #8
0
def init_pc_db():
    db = DB('jfe.db')
    um = UserModel(db.get_connection())
    um.init_table()
    um.insert('test1', 'test1', '-')
    um.insert('test2', 'test2', '-')
    um.insert('admin', 'admin', '-', True)
    nm = NoteModel(db.get_connection())
    nm.init_table()
    pm = ParamModel(db.get_connection())
    pm.init_table()
    vm = VacModel(db.get_connection())
    vm.init_table()
Exemple #9
0
def init_tm_db():
    db = DB('tm.db')
    um = UserModel(db.get_connection())
    um.init_table()
    um.insert(394406731, 'Danya', boss=True)
    um.insert(1027909953, 'Maxim', boss=False)
    # um.insert(1027909953, 'Maxim')
    # um.insert(1579583, 'Евгений Викторович', boss=True)
    # um.insert(60880374, 'Виталий Викторович', boss=True)

    pm = ProjectModel(db.get_connection())
    pm.init_table()

    tm = TaskModel(db.get_connection())
    tm.init_table()

    em = EmployeeModel(db.get_connection())
    em.init_table()
    em.auto_update()
Exemple #10
0
def view_tm_db():
    db = DB('tm.db')
    um = UserModel(db.get_connection())
    print('Пользователи: ', um.get_all())

    print('-----------------------------------------------')

    pm = ProjectModel(db.get_connection())
    print('Проекты: ', pm.get_all())

    print('-----------------------------------------------')

    em = EmployeeModel(db.get_connection())
    print('Сотрудники: ', em.get_all())

    print('-----------------------------------------------')

    tm = TaskModel(db.get_connection())
    print('Задачи: ', tm.get_all())
Exemple #11
0
def start(bot, update):
    global is_add_project, is_add_task, is_add_employee, is_delete_project, is_delete_task, is_delete_employee
    global is_proj_add_task, is_proj_delete_task, is_report_proj, is_report_employee
    global is_report, is_task_selected, is_time_selected

    is_add_project = False
    is_add_task = False
    is_add_employee = False
    is_delete_project = False
    is_delete_task = False
    is_delete_employee = False
    is_task_selected = False
    is_time_selected = False
    is_proj_add_task = False
    is_proj_delete_task = False

    is_report = False
    is_report_proj = False
    is_report_employee = False

    um = UserModel(db.get_connection())
    tg_id = update.message.from_user.id
    print(update.message['chat']['username'])
    # Левый чувак
    if not um.get(tg_id):
        update.message.reply_text(
            f'<b>Вас нет в нашей базе данных.\nВаш ID: {tg_id}</b>',
            reply_markup=ReplyKeyboardRemove(),
            parse_mode='HTML')
    # Босс
    elif um.get(tg_id)[2]:
        update.message.reply_text('<b>Добро пожаловать, Лидер команды!</b>',
                                  reply_markup=create_main_boss_keyboard(),
                                  parse_mode='HTML')
    # Сотрудник
    else:
        update.message.reply_text('<b>Добро пожаловать!</b>',
                                  reply_markup=create_main_employee_keyboard(),
                                  parse_mode='HTML')
Exemple #12
0
 def POST(self):
     data = web.input()
     user_model = UserModel.UserModel()
     user_model.create_user(data)
Exemple #13
0
 def make_user(self, data, **kwargs):
     return UserModel(**data)