def get_all_tasks(message): '''обновим в бд все server_task_id согласно полученному сообщению''' print('get all tasks->', message) # da = data['db'].get_all_tasks() # notification(da) put_message(message) if message['body']['code'] == 200: for server_task_id, task_ in message['body']['message'].items(): task_id = data['db'].get_task_id_by_name(task_.get('name')) if task_id: data['db'].set_task_id(task_id, server_task_id) data['db'].change_date_reminder(task_id, task_.get('date_reminder')) data['db'].change_time_reminder(task_id, task_.get('time_reminder')) else: creator = data['username'] task = Task(creator=creator, viewer=creator, name=task_.get('name')) task.id = int(server_task_id) task.description = task_.get('description') task.date_reminder = task_.get('date_reminder') task.time_reminder = task_.get('time_reminder') task = task.task_dict print('task->', task) data['db'].add_task(task) da = data['db'].get_all_tasks() print('da', da) notification(da) release_queue()
def create_task(message): if message['body']['code'] == 201: creator = data['username'] server_task_id = message['body'].get('id') task_name = data['create_task']['body'].get('name') task_description = data['create_task']['body'].get('description') task_date_reminder = data['create_task']['body'].get('date_reminder') task_time_reminder = data['create_task']['body'].get('time_reminder') data.pop('create_task') task = Task(creator=creator, viewer=creator, name=task_name) task.date_reminder = task_date_reminder task.time_reminder = task_time_reminder task.description = task_description task.id = int(server_task_id) task = task.task_dict print('task->', task) data['db'].add_task(task) else: print(message['body']['code'], message['body']['message']) put_message(message) release_queue()