Exemple #1
0
def get_card_description(card_id, api_response = True):

    '''Returns the dexcription of the card of which the id is associated'''

    card = card_select.card_description(card_id)

    return response.success(card.serialize())
def get_current_sprint(project_id, api_response = True):

    sprint = sprint_select.current_sprint(project_id)

    if api_response:
        return response.success(json.dumps(sprint.serialize()))
    else:
        return sprint.serialize()
def get_current_sprint_with_cards(project_id):
    sprint = sprint_select.current_sprint(project_id)
    standard_cards = card_select.standard_cards_from_sprint(sprint)

    for card in standard_cards:
        sprint.add_card(card)

    return response.success(sprint.serialize())
Exemple #4
0
def sprint_for(card_id, sprint_id, cursor = None):

    cursor.execute("""
            UPDATE card
                SET sprint = %(sprint_id)s
            WHERE card.id = %(card_id)s;""",
            {'card_id' : card_id, 'sprint_id' : sprint_id})

    return response.success()
Exemple #5
0
def get_archive(project_id):

    '''Returns all closed Cards'''

    archive = card_select.archive(project_id)

    serialized_archive = serialize_array(archive)
    
    return response.success(serialized_archive)
Exemple #6
0
def get_active_epics(project_id):

    epics = card_select.active_epics(project_id)

    serialized_epics = []
    for epic in epics:
        serialized_epics.append(epic.serialize())

    return response.success(serialized_epics)
Exemple #7
0
def get_card_details(card_id, api_response = True):

    '''this returns the section containing 
    the epic, poc, creation date, and updated date'''
    #TODO, consider better naming

    card = card_select.card_details(card_id)

    return response.success(card.serialize())
Exemple #8
0
def get_backlog(project_id):

    '''Returns all cards that are open, but not assigned to a sprint'''

    backlog = card_select.backlog(project_id)

    serialized_backlog = serialize_array(backlog)
    
    return response.success(serialized_backlog)
def initialize_creation_page(project_id):
    index = get_next_index(project_id);
    statuses = get_statuses();
    users = get_users(project_id);
    epics = get_epics(project_id);

    data = '{{"card_index" : "{index}", "statuses" : {statuses} , "users" : {users}, "epics": {epics} }}'.format(
        index = index, statuses = statuses, users = users, epics = epics)
    
    return response.success(json.loads(data))
def get_project(project_id, api_response = True):

    project = project_select.project(project_id)

    serialized_project = project.serialize()
    
    if api_response:
        return response.success(serialized_project)
    else:
        return serialized_project
Exemple #11
0
def initialize_home_page(project_id):

    cards = card_workflow.get_card_with_user_task(project_id, api_response = False)
    sprint = sprint_workflow.get_current_sprint(project_id, api_response = False)
    project = project_workflow.get_project(project_id, api_response = False)

    data = '{{"cards" : {cards}, "sprint" : {sprint} , "project" : {project} }}'.format(
        cards = json.dumps(cards), sprint = json.dumps(sprint), project = json.dumps(project))

    return response.success(json.loads(data))
Exemple #12
0
def name(card, cursor = None):

    cursor.execute("""
        UPDATE card
            SET card.name = %(card_name)s,
                card.updated = NOW()
        WHERE card.id = %(card_id)s""",
        {'card_id': card.id, 'card_name': card.name})

    return response.success()
Exemple #13
0
def new_card(card, cursor = None):
    
    cursor.execute("""INSERT INTO  card ( 
                            project,
                            proj_number, 
                            name, 
                            type, 
                            epic, 
                            created, 
                            updated, 
                            status, 
                            points, 
                            poc)
                        values ( 
                            %(project)s,
                            %(proj_num)s, 
                            %(name)s, 
                            %(type)s, 
                            %(epic)s, 
                            NOW(), 
                            NOW(), 
                            %(status)s, 
                            %(points)s, 
                            %(poc)s);""",
                {'project': card.project, 'proj_num': card.proj_number(), 'name': card.name, 'type':CardType[card.type].value, 
                 'epic': card.epic.id, 'status' : Status[card.status].value, 'points': card.points, 'poc' : card.poc.id})

    cursor.execute("""SELECT LAST_INSERT_ID();""")
    new_id = cursor.fetchone()
    
    cursor.execute("""INSERT INTO  card_description (
                            card_id, 
                            description)
                       values (
                            %(card_id)s, 
                            %(description)s)""",
                {'card_id': new_id['LAST_INSERT_ID()'], 'description': card.description})

    
    for step in card.steps:
        
        cursor.execute("""INSERT INTO card_steps (
                                card_id, 
                                task, 
                                assigned, 
                                status)
                            values (
                                %(card_id)s, 
                                %(task)s, 
                                %(assigned_to)s, 
                                %(status)s)""",
                    {'card_id': new_id['LAST_INSERT_ID()'], 'task' : step.task, 'assigned_to': step.assigned.id, 'status': Status[step.status].value})

    return response.success()
Exemple #14
0
def description(card, cursor = None):

    cursor.execute("""
        UPDATE card, card_description
            SET card_description.description = %(card_description)s,
                card.updated = NOW()
        WHERE card_description.card_id = %(card_id)s AND
              card.id =  %(card_id)s""",
        {'card_id': card.id, 'card_description': card.description})

    return response.success()
Exemple #15
0
def new_epic(card, cursor = None):
    
    cursor.execute("""INSERT INTO  card (
                            project, 
                            proj_number, 
                            name, 
                            type, 
                            created, 
                            updated, 
                            status, 
                            points, 
                            poc)
                        values (
                            %(project)s,
                            %(proj_num)s, 
                            %(name)s, %(type)s,  
                            NOW(), 
                            NOW(), 
                            %(status)s, 
                            %(points)s, 
                            %(poc)s);""",
                {'project': card.project, 'proj_num': card.proj_number(), 'name': card.name, 'type':CardType[card.type].value, 
                 'status' : Status[card.status].value, 'points': card.points, 'poc' : card.poc.id})

    cursor.execute("""SELECT LAST_INSERT_ID();""")
    card_id = cursor.fetchone()

    cursor.execute("""INSERT INTO  card_description (
                            card_id, 
                            description)
                       values (
                            %(card_id)s, 
                            %(description)s)""",
                {'card_id': card_id['LAST_INSERT_ID()'], 'description': card.description})
    
    cursor.execute("""INSERT INTO  epic (
                            background_color,
                            foreground_color)
                       values (
                            %(background_color)s,
                            %(foreground_color)s)""",
                {'background_color': card.epic.background_color, 'foreground_color': card.epic.foreground_color})
    
    cursor.execute("""SELECT LAST_INSERT_ID();""")
    epic_id = cursor.fetchone()
        
    cursor.execute("""UPDATE card
                        SET card.epic = %(epic)s
                    WHERE card.id = %(card_id)s""",
                {'card_id': card_id['LAST_INSERT_ID()'], 'epic': epic_id['LAST_INSERT_ID()']})


    return response.success()
Exemple #16
0
def token(token, cursor = None):

    print(token.serialize())
    cursor.execute("""
            UPDATE user
                SET     user.token = %(value)s, 
                        user.token_exp = DATE_ADD(NOW(), INTERVAL 4 HOUR)
            
            WHERE   user.id = %(id)s ;""",
                    {'value': token.token_value, 'id': token.user_id} )

    return response.success()
Exemple #17
0
def steps(steps, cursor = None):

    for step in steps: 

        cursor.execute("""
            UPDATE card_steps
                SET card_steps.task = %(step_task)s, 
                    card_steps.assigned = %(step_assigned)s,
                    card_steps.status = %(step_status)s
            WHERE card_steps.id = %(step_id)s""",
            {'step_id': step.id, 'step_assigned' : step.assigned.id, 'step_status': Status[step.status].value, 'step_task': step.task})

    return response.success()
Exemple #18
0
def details(card, cursor = None):

    cursor.execute("""
        UPDATE card
            SET card.epic = %(card_epic)s, 
                card.status = %(card_status)s,
                card.points = %(card_points)s,
                card.poc = %(card_poc)s,
                card.updated = NOW()
        WHERE card.id = %(card_id)s""",
        {'card_id': card.id, 'card_epic': card.epic.id, 'card_status': Status[card.status].value, 'card_points': card.points, 'card_poc' : card.poc.id})

    return response.success()
def get_projects_for_user():

    token_form = json.loads(request.form['token'])
    token_form = sanitize.form_keys(token_form)

    token = Token.map_from_form(token_form)

    projects = project_select.projects_for_user(token.user_id)

    serialized_projects = []
    for project in projects:
        serialized_projects.append(project.serialize())

    return response.success(serialized_projects)
def create_project(api_response = True):

    project_form = sanitize.form_keys(json.loads(request.form['payload']))
    project = Project.map_from_form(project_form)

    token_form = sanitize.form_keys(json.loads(request.form['token']))
    token = Token.map_from_form(token_form)

    project = project_insert.create_project(project, token.user_id)

    parent_url = "api/DAL/images/projects/"
    project.image.save_to_file_system(parent_url)

    return response.success(project.id)
Exemple #21
0
def new_user(credentials, cursor = None):

    cursor.execute('''
        INSERT user (
                email, 
                first_name, 
                last_name, 
                password)
            VALUES (
                %(email)s, 
                %(first_name)s, 
                %(last_name)s, 
                %(password)s);''',
            {'email': credentials.email, 'first_name' : credentials.first_name, 'last_name': credentials.last_name, 'password' : credentials.password})

    return response.success()
Exemple #22
0
def open_sprint(sprint, cursor = None):
    cursor.execute('''
        INSERT sprint (
                name, 
                start_date, 
                end_date, 
                open,
                project)
            VALUES (
                %(name)s, 
                NOW(), 
                DATE_ADD(NOW(), INTERVAL %(end_date)s WEEK), 
                1,
                %(project)s);''',
            {'name': sprint.name, 'end_date' : sprint.end_date, 'project': sprint.project})

    return response.success()
Exemple #23
0
def steps_for(card_id, steps, cursor = None):

    for step in steps:
        
        cursor.execute("""INSERT INTO card_steps (
                            card_id, 
                            task, 
                            assigned, 
                            status)
                        values (
                            (SELECT id from card WHERE card.id = %(card_id)s),
                            %(task)s, 
                            %(assigned_to)s, 
                            %(status)s)""",

                    {'card_id': card_id, 'task' : step.task, 'assigned_to': step.assigned.id, 'status': Status[step.status].value})

    return response.success()
Exemple #24
0
def get_card_with_user_task(project_id, api_response = True):

    '''Using the user id on the authentication token, send back all cards that
    have steps or are in anyway assigned to the user'''

    token_form = json.loads(request.form['token'])
    token_form = sanitize.form_keys(token_form)

    token = Token.map_from_form(token_form)

    cards = card_select.card_with_user_task(token.user_id, project_id)

    serialized_cards = serialize_array(cards)

    if api_response:
        return response.success(serialized_cards)
    else:
        return serialized_cards
Exemple #25
0
def get_card(card_index, project_id):

    '''Using the cards index, send back all information pertaining to the card
    Used primarily for the card details page'''

    card_refrence = Card()
    card_refrence.index = card_index

    card = card_select.card(project_id, card_refrence.proj_number())

    if card.type is CardType(0).name:
        steps = card_select.card_steps(card.id)
        card.add_steps(steps)

    elif card.type is CardType(1).name:
        assigned_cards = card_select.cards_assigned_to_epic(card.epic.id)
        card.add_assigned_cards(assigned_cards)

    return response.success(card.serialize())
Exemple #26
0
def close_current_sprint(sprint_id, cursor=None):

    cursor.execute(
        """
            UPDATE card
                SET     card.sprint = NULL
            WHERE   card.sprint = %(sprint_id)s AND
                    card.status <> 3;""",
        {"sprint_id": sprint_id},
    )

    cursor.execute(
        """
            UPDATE sprint
                SET     sprint.open = 0, 
                        sprint.closed_date = NOW()
            WHERE   sprint.id = %(sprint_id)s;""",
        {"sprint_id": sprint_id},
    )

    return response.success()
Exemple #27
0
def update_card_steps(card_id):

    '''Updates the steps of the provided card,
    then returns the value from the database'''

    steps_form = json.loads(request.form['payload'])
    steps = create_objects_from_form_array(Step, steps_form) 

    updated_steps = []
    new_steps = []

    for step in steps:
        if step.id > 0:
            updated_steps.append(step)
        else:
            new_steps.append(step)

    card_update.steps(updated_steps)
    card_insert.steps_for(card_id, new_steps)

    steps = card_select.card_steps(card_id)

    return response.success(serialize_array(steps))
Exemple #28
0
def get_card_name(card_id, api_response = True):

    card = card_select.card_name(card_id)
    
    return response.success(card.serialize())