def add_comment(input_data):
    '''
    Add comment to particular backlog
    '''

    comment_uid = str(uuid.uuid1())
    created_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    comment = Comment(comment_uid=comment_uid,
                      content=input_data.get("content"),
                      author=input_data.get("author"),
                      created_at=created_at)

    try:
        backlog_obj = Backlog.objects.get(
            backlog_uid=input_data.get("backlog_uid"))
        backlog_obj.comments.append(comment)
        backlog = backlog_obj.save()
        backlog_data = BacklogResponseSerializer(
            get_backlog(input_data.get('backlog_uid'))).data
        add_activity(
            backlog_data['project_uid'],
            " added comment '" + input_data.get("content") + "' in backlog '" +
            backlog_data['backlog_name'] + "'.", input_data.get('author'))
    except (Exception):
        print(Exception.message)
    else:
        for comment in backlog['comments']:
            if comment['comment_uid'] == comment_uid:
                return comment
    return None
Пример #2
0
def add_backlog(input_data):
    '''
    Add new backlog
    '''

    backlog_uid = str(uuid.uuid1())
    created_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    date_modified = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    status = "New"
    assigned_to = "Unassigned"
    iteration_uid = ""
    actual_start_date = None
    actual_end_date = None
    actual_efforts = None
    is_notified = False
    completed_at = None

    try:
        backlog_obj = Backlog(
            backlog_name=input_data.get('backlog_name'),
            backlog_uid=backlog_uid,
            project_uid=input_data.get('project_uid'),
            iteration_uid=iteration_uid,
            backlog_description=input_data.get('backlog_description'),
            assigned_to=assigned_to,
            created_at=created_at,
            date_modified=date_modified,
            planned_start_date=input_data.get('planned_start_date'),
            actual_start_date=actual_start_date,
            planned_end_date=str(input_data.get('planned_end_date')),
            actual_end_date=actual_end_date,
            estimated_efforts=input_data.get('estimated_efforts'),
            actual_efforts=actual_efforts,
            is_notified=is_notified,
            completed_at=completed_at,
            status=status).save()
        project_data = ProjectResponseSerializer(
            get_project(input_data.get("project_uid"))).data
        add_activity(
            input_data.get("project_uid"), " added backlog '" +
            input_data.get("backlog_name") + "' in this project.",
            project_data['owned_by'])
    except (Exception):
        print(Exception.message)
    else:
        return backlog_obj
def delete_comment(comment_uid):
    '''
    Delete comment using comment_uid
    '''
    try:
        backlog = Backlog.objects.get(comments__comment_uid=comment_uid)
        comment_data = CommentSerializer(get_comment(comment_uid)).data
        backlog_data = BacklogResponseSerializer(backlog).data
        result = backlog.update(pull__comments__comment_uid=comment_uid)
        add_activity(
            backlog_data['project_uid'],
            " deleted comment '" + comment_data['content'] + "' in backlog '" +
            backlog_data['backlog_name'] + "'.", comment_data['author'])
    except (Exception):
        print(Exception.message)
    else:
        return True
    return None
def update_project(input_dict):
    """
    Editing and updating required fields of project.
    """
    date_modified = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    try:
        project_obj = Project.objects(project_uid=input_dict.get('project_uid'))\
                                    .update(project_name=input_dict.get('project_name'),
                                            project_description=input_dict.get('project_description'),
                                            start_date = input_dict.get('start_date'),
                                            date_modified=date_modified,
                                            owned_by=input_dict.get('owned_by'))
        add_activity(input_dict.get('project_uid'), " modified this project.",
                     input_dict.get('owned_by'))
    except (Exception):
        print(Exception)
    else:
        return project_obj
    return None
Пример #5
0
def delete_backlog(backlog_uid):
    '''
    Delete backlog
    '''
    try:
        backlog_obj = Backlog.objects(backlog_uid=backlog_uid)
        backlog_data = BacklogResponseSerializer(get_backlog(backlog_uid)).data
        result = backlog_obj.delete()
        project_data = ProjectResponseSerializer(
            get_project(backlog_data['project_uid'])).data
        add_activity(
            backlog_data['project_uid'],
            " deleted backlog '" + backlog_data['backlog_name'] + "'.",
            project_data['owned_by'])
    except (Exception):
        print(Exception.message)
    else:
        return result
    return None