예제 #1
0
    def post(self):
        json = request.get_json()

        issue = Issue()
        issue.summary = json.get("summary")
        issue.description = json.get("description")
        reporter = json.get("reporter")
        assignee = json.get("assignee")
        issue.reporter = GitUser(email=reporter.get(
            "email")) if reporter is not None else GitUser()
        issue.assignee = GitUser(
            email=assignee.get("email")) if assignee is not None else None

        issue.subscribers.append(issue.reporter)
        if issue.assignee is not None and issue.assignee not in issue.subscribers:
            issue.subscribers.append(issue.assignee)

        gm = GitManager()
        handler = gm.perform_git_workflow(lambda: IssueHandler())
        created_issue = handler.store_issue(issue,
                                            "create",
                                            generate_id=True,
                                            store_tracker=True)
        result = to_payload(GitUser(), issue, IssueSchema)

        return result.data, HTTPStatus.CREATED, {
            'location': f'issues/${created_issue.id}'
        }
예제 #2
0
def issue_3():
    issue = Issue()
    issue.id = "ISSUE-3"
    issue.uuid = 53368803138698180295652887974160049016
    issue.date = "2018-02-25T22:33:58.00000"
    issue.description = "description-of-issue-3"
    issue.summary = "summary-of-issue-3"
    return issue
예제 #3
0
def regular_issue(tracker):
    issue = Issue()
    issue.id = "ISSUE-30"
    issue.assignee = "liam"
    issue.reporter = "bob"
    issue.description = "description"
    issue.summary = "summary"
    return issue
예제 #4
0
def issue_2():
    issue = Issue()
    issue.id = "ISSUE-2"
    issue.uuid = 219614693126630377445621689697662132760
    issue.date = "2018-02-25T22:33:56.97968"
    issue.assignee = GitUser("liam", "*****@*****.**")
    issue.reporter = GitUser("bob", "*****@*****.**")
    issue.description = "description-of-issue-2"
    issue.summary = "summary-of-issue-2"
    return issue
예제 #5
0
def issue_1():
    issue = Issue()
    issue.id = "ISSUE-1"
    issue.date = "2018-02-25T22:33:50.04040"
    issue.uuid = 125118048431737826035520921347116368363
    issue.assignee = GitUser("liam", "*****@*****.**")
    issue.reporter = GitUser("bob", "*****@*****.**")
    issue.description = "description-of-issue-1"
    issue.summary = "summary-of-issue-1"
    return issue
예제 #6
0
def create(args):
    issue = Issue()
    issue.summary = args.summary
    issue.description = args.description
    issue.assignee = GitUser(email=args.assignee) if args.assignee != None else None
    issue.reporter = GitUser(email=args.reporter)
    issue.subscribers.append(GitUser())

    def operation():
        handler = GitManager().perform_git_workflow(lambda: IssueHandler())
        new_issue = handler.store_issue(issue, "creation", True, True)
        print(f"ID of newly created issue: {new_issue.id}")

    confirm_operation(issue, operation)
예제 #7
0
def edit_issue_form(id):
    form = EditForm(request.form)

    if form.validate():
        issue = Issue()
        issue.id = id
        issue.summary = form.summary.data
        issue.description = form.description.data
        issue.reporter = GitUser(
            form.reporter.data) if form.reporter.data != "" else None
        issue.assignee = GitUser(
            form.assignee.data) if form.assignee.data != "" else None
        issue.status = form.status.data

        user = GitUser()
        if (form.subscribed.data):
            matches = [
                sub for sub in issue.subscribers if sub.email == user.email
            ]

            if (len(matches) == 0):
                issue.subscribers.append(user)
        else:
            issue.subscribers = [
                sub for sub in issue.subscribers if sub.email != user.email()
            ]

        issue = handler.store_issue(issue, "edit")

        return render_template("single_issue.html", issue=issue)

    issue = handler.get_issue(id)

    if issue is None:
        return render_template("error_page.html",
                               error_msg=f"Issue {id} not found.")

    form.summary.data = issue.summary
    form.description.data = issue.description
    form.status.data = issue.status
    form.subscribed.data = False  # This needs changed to check if git user is subscribed

    if (issue.reporter is not None):
        form.reporter.data = issue.reporter.email

    if (issue.assignee is not None):
        form.assignee.data = issue.assignee.email

    return render_template("edit_issue.html", form=form, issue=issue)
예제 #8
0
def create_issue_form():
    form = CreateForm(request.form)

    if form.validate():
        issue = Issue()
        issue.summary = form.summary.data
        issue.description = form.description.data
        issue.reporter = GitUser(
            form.reporter.data) if form.reporter.data != "" else GitUser()
        issue.assignee = GitUser(
            form.assignee.data) if form.assignee.data != "" else None
        issue = handler.store_issue(issue, "edit", generate_id=True)

        return render_template("single_issue.html", issue=issue)

    return render_template("create_issue.html", form=form)
예제 #9
0
def test_get_all_issues(monkeypatch, tmpdir, regular_issue, test_repo):
    expected = [regular_issue, Issue("ISSUE-NA")]

    dirs = []
    tmpdir.mkdir("/issue")
    root = f"{test_repo.working_dir}/issue"
    dirs.append(create_tmp_file(root, expected[0]))
    dirs.append(create_tmp_file(root, expected[1]))

    print(dirs)

    result = handler.get_all_issues()

    expected.sort(key=lambda x: x.id)
    result.sort(key=lambda x: x.id)

    assert len(expected) == len(result)
    assert expected[0].id == result[0].id and expected[1].id == result[1].id
예제 #10
0
 def make_issue(self, data):
     return Issue(**data)