Esempio n. 1
0
def proccess_edit_name_project(parsed):
    username = getattr(parsed, 'username', None)
    password = getattr(parsed, 'password', None)
    pid = getattr(parsed, 'project id', None)
    name = getattr(parsed, 'name', None)
    ProjectController.edit_name_by_id(username, password, pid, name)
    pr_pres.success_edit()
Esempio n. 2
0
def proccess_edit_description_project(parsed):
    username = getattr(parsed, 'username', None)
    password = getattr(parsed, 'password', None)
    pid = getattr(parsed, 'project id', None)
    description = getattr(parsed, 'description', None)
    ProjectController.edit_description_by_id(username, password, pid,
                                             description)
    pr_pres.success_edit()
Esempio n. 3
0
def parse_project(subcategory, args):
    """
    "Project" handler
    :param subcategory:
    :param args:
    :return:
    """
    log_tag = "parse_project"
    log = logger.get_logger(log_tag)
    if subcategory == SubCategories.add:
        if len(args) != 4:
            log.error(
                "Incorrect number of arguments. Expected {} , but {} was recieved"
                .format(4, len(args)))
            project_view.add_format()
        else:
            log.info(
                "Trying to create a project with the name - {} and description - {}"
                .format(args[2], args[3]))
            project = ProjectController.create(args[0], args[1], args[2],
                                               args[3])
            project_view.success_create(project)
            log.info("Project {} was successfully created".format(args[2]))
    elif subcategory == SubCategories.delete:
        if len(args) != 3:
            log.error(
                "Incorrect number of arguments. Expected {}, but {} was recieved"
                .format(3, len(args)))
            delete_format()
        else:
            log.info("Trying to delete a project {}".format(args[2]))
            ProjectController.delete(args[0], args[1], args[2])
            project_view.success_delete()
            log.info("Project {} is successfully deleted".format(args[2]))
    elif subcategory == SubCategories.show:
        if len(args) != 3:
            incorrent_args_len()
            log.error(
                "Incorrect number of arguments. Expected {} , but {} was recieved"
                .format(4, len(args)))
        else:
            if args[0] == 'all':
                log.info("Trying to show all projects of this user")
                projects = ProjectController.show_all(args[1], args[2])
                project_view.show_info(projects)
                log.info("All project was shown")
    elif subcategory == SubCategories.edit:
        if len(args) != 5:
            project_view.edit_format()
            log.error(
                "Incorrect number of arguments. Expected {} , but {} was recieved"
                .format(4, len(args)))
        else:
            if args[0] == 'name':
                log.info("Trying to change the name of '{}' project".format(
                    args[3]))
                ProjectController.edit_name(args[1], args[2], args[3], args[4])
                project_view.success_edit()
                log.info("Project is successfully edited")
            if args[0] == 'description' or 'desc':
                log.info(
                    "Trying to change the description of  '{}' project".format(
                        args[3]))
                ProjectController.edit_description(args[1], args[2], args[3],
                                                   args[4])
                project_view.success_edit()
                log.info("Project is successfully edited")
            else:
                print(project_view.edit_format())
                log.error("Incorrect format")
    elif subcategory == SubCategories.members:
        if len(args) != 5:
            members_add_format()
            log.error(
                "Incorrect number of arguments. Expected {} , but {} was recieved"
                .format(4, len(args)))
        else:
            if args[0] == 'add':
                log.info("Trying to add {} to '{}' project".format(
                    args[4], args[3]))
                ProjectController.add_person_to_project(
                    args[1], args[2], args[3], args[4])
                log.info("User is successfully added to the project")
                project_view.user_added()
            elif args[0] == 'delete':
                ProjectController.delete_person_from_project(
                    args[1], args[2], args[3], args[4])
                log.info(("Trying to delete {} from '{}' project".format(
                    args[3], args[4])))
                log.info("User is successfully deleted from project")
                project_view.user_deleted()
            else:
                members_add_format()