Exemple #1
0
def select_roles_referential():
    select_query = select([ROLE_REFERENTIAL_TABLE])
    rows = connection.execute(select_query)
    roles = []
    for row in rows:
        roles.append(row['role'])
    return roles
Exemple #2
0
def insert_project(project_id, project_name, project_type):
    insert = PROJECT_TABLE.insert().values(project_id=project_id,
                                           project_name=project_name,
                                           project_type=project_type)
    try:
        result = connection.execute(insert)
    except Exception as ex:
        print('Error occured : ' + str(ex))
Exemple #3
0
def insert_role_for_user(email, project_id, role):
    insert = USER_PROJECT_ROLE_TABLE.insert().values(email=email,
                                                     project_id=project_id,
                                                     role=role)
    try:
        result = connection.execute(insert)
    except Exception as ex:
        print('Error occured : ' + str(ex))
Exemple #4
0
def insert_task(task_id, task_type, labels, project_id):
    insert = TASK_TABLE.insert().values(task_id=task_id,
                                        task_type=task_type,
                                        project_id=project_id,
                                        labels=labels)
    try:
        result = connection.execute(insert)
    except Exception as ex:
        print('Error occured : ' + str(ex))
Exemple #5
0
def insert_user(email, last_name, first_name):
    insert = USERS_TABLE.insert().values(email=email,
                                         last_name=last_name,
                                         first_name=first_name,
                                         is_deleted=False)
    try:
        result = connection.execute(insert)
    except Exception as ex:
        print('Error occured : ' + str(ex))
Exemple #6
0
def select_projects():
    select_query = select([PROJECT_TABLE])
    rows = connection.execute(select_query)
    projects = []
    for row in rows:
        projects.append(
            Project(project_id=row['project_id'],
                    project_name=row['project_name'],
                    project_type=row['project_type'],
                    tasks=None))
    return projects
Exemple #7
0
def select_users():
    select_query = select([USERS_TABLE
                           ]).where(USERS_TABLE.c.is_delete is False)
    rows = connection.execute(select_query)
    users = []
    for row in rows:
        users.append(
            User(email=row['email'],
                 first_name=row['first_name'],
                 last_name=row['last_name']))
    return users
Exemple #8
0
def select_tasks():
    select_query = select([TASK_TABLE])
    rows = connection.execute(select_query)
    tasks = []
    print(rows == None)
    for row in rows:
        tasks.append(
            Task(task_id=row['task_id'],
                 task_type=row['task_type'],
                 project_id=row['project_id'],
                 labels=row['labels']))
    print(len(tasks))
    return tasks
Exemple #9
0
def select_projects_roles_by_user(email):
    join_tables = USERS_TABLE.join(
        USER_PROJECT_ROLE_TABLE,
        USERS_TABLE.c.email == USER_PROJECT_ROLE_TABLE.c.email)
    query = select([
        USER_PROJECT_ROLE_TABLE.c.email, USER_PROJECT_ROLE_TABLE.c.project_id,
        USER_PROJECT_ROLE_TABLE.c.role
    ]).select_from(join_tables).where(USER_PROJECT_ROLE_TABLE.c.email == email)
    rows = connection.execute(query)
    users = []
    for row in rows:
        users.append(
            UserProjectRole(email=row['email'],
                            project_id=row['project_id'],
                            role=row['role']))
    return users
Exemple #10
0
def insert_role_to_referential(role):
    insert = ROLE_REFERENTIAL_TABLE.insert().values(role=role)
    try:
        result = connection.execute(insert)
    except Exception as ex:
        print('Error occured : ' + str(ex))