def change_password(cls, login, password, new_password, question, answer): user = UsersFunctions.get_user_by_login_and_password(login, password) if user is None: print("Данного пользователя не существует, проверьте пароль") else: user = User(login=login, password=password, question=question, answer=answer) UsersFunctions.change_user_password(user, new_password)
def registration(cls, login, password, question, answer): try: user = User(login=login, password=password, question=question, answer=answer) UsersFunctions.add_user(user) except IntegrityError as e: exception = e.args[0] print(exception[120:])
def change_status(cls, login, password, id, status): "Yes" user = UsersFunctions.get_user_by_login_and_password(login, password) task = TaskFunctions.get_task_by_id(id) if user is None: print("Пароль или логин введен неверно") elif task is None: print("Данной задачи не существует") elif task.owner != login: print("Вы не являетесь создателем данной задачи") else: task = Task(id=id, status=status, comment=None, date_of_create=None, priority=None, time_of_create=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, is_linked=None, linked_task_id=None, expert=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.change_task_status(task) if status == 'Выполнено': TaskChangeMethods.change_status_of_childs_tasks(id) TaskChangeMethods.change_parent_task(id)
def change_task(cls, login, password, id, header, priority, tags, comment): "Yes" is_user_valid = UsersFunctions.get_user_by_login_and_password( login, password) is_task_valid = TaskFunctions.get_task_by_id(id) if is_user_valid is None: print("Пароль или логин введен неверно") elif is_task_valid is None: print("Данной задачи не существует") elif is_task_valid.owner != login: print("Вы не являетесь создателем данной задачи") else: task = Task(id=id, header=header, priority=priority, tags=tags, comment=comment, date_of_create=None, time_of_create=None, is_under_task=None, owner=None, status=None, parent_task_id=None, is_linked=None, linked_task_id=None, expert=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.change_task(task)
def search_by_status(cls, login, password, search_info): "Yes" tasks = TaskFunctions.search_by_header(search_info) is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) if is_valid_user is None: print("Пароль или логин введен неверно") else: for task in tasks: is_archive = ArchiveTask.is_task_archive(task) if is_archive is False and (task.owner == login or task.expert == login): print(task) # if __name__ == '__main__': # ArchiveTask.search_by_status('aa','aa', 'Задача 3') # ArchiveTask.print_non_archived_tasks('aa','aa') # ArchiveTask.group_by_tags('aa', 'aa') # TaskChangeMethods.change_parent_task(10) # i = 0 # while i != 5: # TaskAddMethods.add_task('aaaa', 'aaaa', 'Здача 3', 'Низкий','Др','Комментарий 3','11-11-2018','16:40','22-11-2018', '16:40', 'Выполняется') # i += 1 # HelpMethods.is_tasks_linked(1,2) # ParentTaskMethods.add_parent_for_task('aa', 'aa', 3, 2, 'aa') # LinkedTaskMethods.add_linked_task('aa', 'aa', 13, 14) # LinkedTaskMethods.delete_link_between_linked_task('aa', 'aa', 10, 11) # ParentTaskMethods.delete_link_between_task('aa','aa', 2, 1) # TaskDeleteMethods.delete_task('aa','aa',3) # LinkedTaskMethods.delete_link_between_linked_task('aa','aa',1,2)
def print_archive(cls, login, password): "Yes" tasks = TaskFunctions.get_all_task() is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) if is_valid_user is None: print("Пароль или логин введен неверно") else: for task in tasks: is_archive = ArchiveTask.is_task_archive(task) if is_archive is True and (task.owner == login or task.expert == login): print(task)
def search_by_tags(cls, login, password, search_info): "Yes" tasks = TaskFunctions.search_by_header(search_info) is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) if is_valid_user is None: print("Пароль или логин введен неверно") else: for task in tasks: is_archive = ArchiveTask.is_task_archive(task) if is_archive is False and (task.owner == login or task.expert == login): print(task)
def delete_task(cls, login, password, task_id): "Yes" user = UsersFunctions.get_user_by_login_and_password(login, password) task = TaskFunctions.get_task_by_id(task_id) if user is None: print("Пароль или логин введен неверно") elif task is None: print("Данной задачи не существует") else: TaskFunctions.delete_task(task_id) TaskDeleteMethods.parse_and_delete_id_from_linked_task( task.linked_task_id, task_id) TaskDeleteMethods.delete_all_childs_of_task(task_id) TaskDeleteMethods.delete_form_childs_task_id(task_id)
def add_task(cls, login, password, header, priority, tags, comment, date_of_start, time_of_start, date_of_end, time_of_end, status): "Yes" user = UsersFunctions.get_user_by_login_and_password(login, password) if datetime.strptime(date_of_end, '%d-%m-%Y') < datetime.strptime( date_of_start, '%d-%m-%Y'): print("Дата окончания не должна превышать дату начала") if user is None: print("Пароль или логин введен неверно") else: correct_date = HelpMethods.check_datetime(date_of_start, date_of_end, time_of_start, time_of_end) if correct_date: task = Task(owner=login, header=header, priority=priority, tags=tags, comment=comment, date_of_start=date_of_start, time_of_start=time_of_start, date_of_end=date_of_end, time_of_end=time_of_end, status=status, id=None, date_of_create=None, time_of_create=None, expert=None, is_linked=None, is_parent_task=None, is_under_task=None, linked_task_id=None, parent_task_id=None, under_task_id=None) TaskFunctions.add_task(task) print("Задача добавлена") else: print( "Одна из дат или время введены неверно, формат даты '11-11-2011', формат время '16:40'" )
def change_task_date(cls, login, password, id, date_of_start, date_of_end, time_of_start, time_of_end): "Yes" user = UsersFunctions.get_user_by_login_and_password(login, password) task = TaskFunctions.get_task_by_id(id) if user is None: print("Пароль или логин введен неверно") elif task is None: print("Данной задачи не существует") elif task.owner != login: print("Вы не являетесь создателем данной задачи") else: correct_date = HelpMethods.check_datetime(date_of_start, date_of_end, time_of_start, time_of_end) if correct_date: task = Task(id=id, date_of_start=date_of_start, time_of_start=time_of_start, date_of_end=date_of_end, time_of_end=time_of_end, comment=None, date_of_create=None, priority=None, time_of_create=None, header=None, is_under_task=None, owner=None, parent_task_id=None, status=None, tags=None, is_linked=None, linked_task_id=None, expert=None, is_parent_task=None, under_task_id=None) TaskFunctions.change_date_time_task(task) else: print("Неверно введены дата или время")
def change_expert(cls, login, password, id, expert): "Yes" user = UsersFunctions.get_user_by_login_and_password(login, password) is_valid_task = TaskFunctions.get_task_by_id(id) is_valid_user = HelpMethods.check_on_valid_user(expert) if user is None: print("Пароль или логин введен неверно") elif is_valid_task is None: print("Данной задачи не существует") elif is_valid_task.owner != login: print("Вы не являетесь создателем данной задачи") else: is_task_under_task = HelpMethods.task_is_under_task(id) if is_task_under_task: task = Task(id=id, expert=expert, comment=None, date_of_create=None, priority=None, time_of_create=None, header=None, is_under_task=None, owner=None, parent_task_id=None, status=None, tags=None, is_linked=None, linked_task_id=None, is_parent_task=None, under_task_id=None, date_of_start=None, date_of_end=None, time_of_end=None, time_of_start=None) TaskFunctions.change_expert(task) else: print( "Данная задача не является подзадачей, вы не можете присвоит ей исполняющего" )
def check_on_valid_user(cls, login): users = UsersFunctions.get_user_by_login(login) if users is None: return False else: return True
def delete_link_between_task(cls, login, password, id, parent_id): "Yes" is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) is_child_has_parent_task = HelpMethods.check_under_task_and_parent_task_linked( id, parent_id) parent_task = TaskFunctions.get_task_by_id(parent_id) child_task = TaskFunctions.get_task_by_id(id) new_str_of_id_for_parent_task = HelpMethods.delete_sub_string_in_string( parent_task.under_task_id, id) if parent_task is None or child_task is None: print("Одной из задач не существует") if is_valid_user is None: print("Пароль или логин введен неверно") if parent_task.owner != login or child_task.owner != login: print("Вы не являетесь создателем данных задач") if parent_task.is_parent_task == "Yes": print("Родительская задача уже является родителем") elif is_child_has_parent_task is False: print("У подзадачи нет родителя") else: new_child_task = Task(id=id, parent_task_id=0, is_under_task='None', expert='None', comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_child(new_child_task) if new_str_of_id_for_parent_task == '': new_parent_task = Task(id=parent_id, is_parent_task='None', under_task_id='None', comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, parent_task_id=None, tags=None, status=None, expert=None, is_under_task=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_parent(new_parent_task) else: new_parent_task = Task( id=parent_id, is_parent_task='Yes', under_task_id=new_str_of_id_for_parent_task, comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, parent_task_id=None, tags=None, status=None, expert=None, is_under_task=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_parent(new_parent_task)
def add_parent_for_task(cls, login, password, id, parent_id, expert): "Yes" is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) is_child_has_parent_task = HelpMethods.is_task_have_parent(id) parent_task = TaskFunctions.get_task_by_id(parent_id) child_task = TaskFunctions.get_task_by_id(id) is_tasks_already_linked = HelpMethods.check_under_task_and_parent_task_linked( parent_id, id) if is_valid_user is None: print("Пароль или логин введен неверно") return "Пароль или логин введен неверно" if parent_task.owner != login or child_task.owner != login: print("Вы не являетесь создателем данных задач") return "Вы не являетесь создателем данных задач" if parent_task.is_parent_task == "Yes": print("Родительская задача уже является родителем") return "Родительская задача уже является родителем" if id == parent_id: print("Вы не можете пометить задаче как родительскую саму себя") return "Вы не можете пометить задаче как родительскую саму себя" if is_child_has_parent_task: print("У данной задачи уже есть родитель") return "У данной задачи уже есть родитель" if is_tasks_already_linked: print("Данные задачи уже связаны") return "Данные задачи уже связаны" if parent_task is None or child_task is None: print("Одной из задач не существует") return "Одной из задач не существует" else: if parent_task.under_task_id == 'None' and parent_task.is_parent_task == 'None': new_parent_task = Task(id=parent_id, under_task_id=str(id) + ',', is_parent_task='Yes', comment=None, date_of_create=None, time_of_create=None, expert=None, priority=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, status=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_parent(new_parent_task) new_child_task = Task(id=id, parent_task_id=parent_id, is_under_task='Yes', expert=expert, comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_child(new_child_task) else: new_parent_task = Task( id=parent_id, under_task_id=parent_task.under_task_id + str(id) + ',', is_parent_task='Yes', expert=expert, comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, tags=None, status=None, is_under_task=None, parent_task_id=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_parent(new_parent_task) new_child_task = Task(id=id, parent_task_id=int(id), is_under_task='Yes', expert=str(expert), comment=None, date_of_create=None, time_of_create=None, priority=None, header=None, owner=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, is_linked=None, linked_task_id=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_child(new_child_task)
def delete_link_between_linked_task(cls, login, password, id, linked_task_id): "Yes" is_valid_user = UsersFunctions.get_user_by_login_and_password( login, password) left_task = TaskFunctions.get_task_by_id(id) right_task = TaskFunctions.get_task_by_id(linked_task_id) is_task_already_linked = HelpMethods.is_tasks_already_linked( id, linked_task_id) new_linked_str_for_left_task = HelpMethods.delete_sub_string_in_string( left_task.linked_task_id, linked_task_id) new_linked_str_for_right_task = HelpMethods.delete_sub_string_in_string( right_task.linked_task_id, id) if is_valid_user is None: print("Пароль или логин введен неверно") elif left_task is None: print("Данной задачи не существует") elif right_task is False: print("Задачи, с которой вы пытаетесь связать, не существует") elif right_task.owner != login or left_task.owner != login: print("Вы не являетесь владельцем данных задач") elif id == linked_task_id: print("Вы не можете связать задачу с самой сабой") elif is_task_already_linked is not True: print("Задачи не связаны") else: if new_linked_str_for_left_task == '': new_task = Task(id=left_task.id, is_linked='None', linked_task_id='None', comment=None, date_of_create=None, time_of_create=None, expert=None, priority=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_linked(new_task) else: new_task = Task(id=left_task.id, is_linked='Yes', linked_task_id=new_linked_str_for_left_task, comment=None, date_of_create=None, time_of_create=None, expert=None, priority=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_linked(new_task) if new_linked_str_for_right_task == '': new_task = Task(id=right_task.id, is_linked='None', linked_task_id='None', comment=None, date_of_create=None, time_of_create=None, expert=None, priority=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_linked(new_task) else: new_task = Task(id=right_task.id, is_linked='Yes', linked_task_id=new_linked_str_for_right_task, comment=None, date_of_create=None, time_of_create=None, expert=None, priority=None, header=None, is_under_task=None, owner=None, parent_task_id=None, tags=None, status=None, is_parent_task=None, under_task_id=None, time_of_start=None, date_of_end=None, date_of_start=None, time_of_end=None) TaskFunctions.actions_linked(new_task)