def get_tasks(project_key, role, user_id):
    if role == "developer":
        return TaskDetails.query(TaskDetails.Project == project_key,
                                 TaskDetails.task_developers == user_id).order(
                                     TaskDetails.task_startdate).fetch()
    return TaskDetails.query(TaskDetails.Project == project_key).order(
        TaskDetails.task_startdate).fetch()
def get_total_allocated_minutes(project_key):
    task_data = TaskDetails.query(TaskDetails.Project == project_key).fetch(
        projection=TaskDetails.task_aminutes)
    total_allocated = 0
    for task in task_data:
        total_allocated += task.task_aminutes
    return total_allocated
def create_task(project_id, Title, aMinutes, start, finish, Description,
                Skills, Developers):
    project = ProjectDetails.get_by_id(int(project_id))
    task_data = TaskDetails(
        Project=project.key,
        task_name=Title,
        task_description=Description,
        task_startdate=datetime.strptime(str(start), '%d/%m/%Y'),
        task_finishbydate=datetime.strptime(str(finish), '%d/%m/%Y'),
        task_skills=map(int, Skills),
        task_developers=map(int, Developers),
        task_aminutes=int(aMinutes),
        task_status="Open")
    if task_data.put():
        return True
    return False
Beispiel #4
0
def get_task(wks_key, TaskID):
    task = TaskDetails.get_by_id(TaskID)
    if task:
        if task.get_wks() == wks_key:
            return task
        return {'code': 403, 'message': "Task (" + str(TaskID) + ") not part of workspace. Forbidden access."}
    return {'code': 404, 'message': "Task not found: " + str(TaskID)}
def delete_log(task_id, log_id):
    log = TaskLog.get_by_id(log_id)
    minutes = log.log_minutes
    log.key.delete()
    task = TaskDetails.get_by_id(task_id)
    if task.remove_minutes(minutes):
        return True
    return False
Beispiel #6
0
def get_log(wks_key,logid):
    log = TaskLog.get_by_id(logid)
    if log:
        task = TaskDetails.get_by_id(log.task_id)
        if task.get_wks() == wks_key:
            return log
        return {'code': 403, 'message': "Log (" + str(logid) + ") not part of workspace. Forbidden access."}
    return {'code': 404, 'message': "Log not found: " + str(logid)}
def get_total_logged_minutes(project_key):
    task_data = TaskDetails.query(
        TaskDetails.Project == project_key,
        TaskDetails.task_logged_minutes != None).fetch(
            projection=TaskDetails.task_logged_minutes)
    total = 0
    for task in task_data:
        total += task.task_logged_minutes
    return total
Beispiel #8
0
def delete_log(log):
    resp = {}
    log_id = log.key.id()
    task_id = log.task_id
    log = TaskLog.get_by_id(log_id)
    minutes = log.log_minutes
    log.key.delete()
    task = TaskDetails.get_by_id(task_id)
    task.remove_minutes(minutes)
    resp['information'] = "Log deleted."
    return resp
Beispiel #9
0
def create_task(wks_key, project, body):
    resp = {}
    validation = validate_task(wks_key, body)
    if validation != True:
        return validation

    task_data = TaskDetails(
        Project=project.key,
        task_name=body['task_name'],
        task_description=body['task_description'],
        task_aminutes=body['task_aminutes'],
        task_skills=body['task_skills'],
        task_developers=body['task_developers'],
        task_status="Open",
        task_startdate=format_date(body['task_startdate']),
        task_finishbydate=format_date(body['task_finishbydate'])
    ).put()
    resp['TaskID'] = task_data.id()
    resp["information"] = "Task created successfully."

    return resp
Beispiel #10
0
def db_tasks(session, client):
    """
    Creates and returns function-scoped database entry for task list
    """
    task_list = TaskList(id=randint(1000, 30000),
                         list_title=' '.join(g.text.title().split(' ')[:5]))

    task_card = TaskCard(id=randint(1000, 30000),
                         card_title=' '.join(g.text.title().split(' ')[:5]),
                         accomplished=False,
                         task_list_id=task_list.id)

    task_details = TaskDetails(id=randint(1000, 30000),
                               task_description=g.text.sentence(),
                               task_card_id=task_card.id)
    yield (task_list, task_card, task_details)
Beispiel #11
0
def update_log(allowed_items,log,body):
    resp = {}
    old_body = body.copy()
    task = TaskDetails.get_by_id(log.task_id)
    for item in allowed_items:
        if item not in body:
            body[item] = getattr(log, item)

    validation = validate_log(task, body)
    if validation != True:
        return validation

    for item in body:
        new_value = body[item]
        setattr(log, item, new_value)
        task.put()
    resp["information"] = str(old_body.keys()) + " updated."

    return resp
Beispiel #12
0
def get_task_data_by_id(task_id):
    return TaskDetails.get_by_id(task_id)
Beispiel #13
0
def get_total_task_number(project_key):
    return TaskDetails.query(TaskDetails.Project == project_key).count()
Beispiel #14
0
def get_open_task_number(project_key):
    return TaskDetails.query(TaskDetails.Project == project_key,
                             TaskDetails.task_status == "Open").count()
Beispiel #15
0
def delete_task(task_id):
    task = TaskDetails.get_by_id(task_id)
    if task.delete():
        return True
    return False
Beispiel #16
0
def get_tasks(project_key):
    return convert_tasks(TaskDetails.query(TaskDetails.Project == project_key).fetch())