From b6223aabce1d4f235cefbfb2eef521eb00616a55 Mon Sep 17 00:00:00 2001 From: Pierre Bastianelli Date: Wed, 18 Sep 2024 12:49:19 -0700 Subject: [PATCH] chore: pages and navigation --- estimation/app/templates/base.html | 2 +- estimation/app/templates/confirm_issue.html | 40 +++++++++++++++++++ estimation/app/templates/dashboard.html | 8 ++-- .../app/templates/estimation_session.html | 17 ++++++++ estimation/app/templates/select_issue.html | 30 ++++++++++++++ estimation/app/urls.py | 3 ++ estimation/app/view_models/__init__.py | 2 + .../view_models/confirm_issue_view_model.py | 7 ++++ .../view_models/select_issue_view_model.py | 5 +++ estimation/app/views/__init__.py | 3 ++ estimation/app/views/confirm_issue.py | 19 +++++++++ estimation/app/views/estimation_session.py | 6 +++ estimation/app/views/select_issue.py | 24 +++++++++++ 13 files changed, 161 insertions(+), 5 deletions(-) create mode 100644 estimation/app/templates/confirm_issue.html create mode 100644 estimation/app/templates/estimation_session.html create mode 100644 estimation/app/view_models/confirm_issue_view_model.py create mode 100644 estimation/app/view_models/select_issue_view_model.py create mode 100644 estimation/app/views/confirm_issue.py create mode 100644 estimation/app/views/estimation_session.py create mode 100644 estimation/app/views/select_issue.py diff --git a/estimation/app/templates/base.html b/estimation/app/templates/base.html index 41242d9..990e013 100644 --- a/estimation/app/templates/base.html +++ b/estimation/app/templates/base.html @@ -51,7 +51,7 @@

GitHub Async Estimation Tool

-
+
{% block content %} {% endblock content %}
diff --git a/estimation/app/templates/confirm_issue.html b/estimation/app/templates/confirm_issue.html new file mode 100644 index 0000000..2c80c06 --- /dev/null +++ b/estimation/app/templates/confirm_issue.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} + +{% block title %} Select Isuse {% endblock %} + + +{% block content %} +
+
+
+
+

Confirm issue to estimate

+
+
+ {% csrf_token %} +
+
+ + +
+
+
+
+

Issue details

+
+
+

ID: {{ issue.issue_id }}

+

Title: The title of the issue goes here

+
+
+
+
+ + Cancel +
+
+
+
+
+
+{% endblock %} diff --git a/estimation/app/templates/dashboard.html b/estimation/app/templates/dashboard.html index f4698ca..8d00377 100644 --- a/estimation/app/templates/dashboard.html +++ b/estimation/app/templates/dashboard.html @@ -6,7 +6,7 @@ {% block content %} -
+
Issues awaiting votes for {{ user.handle }}@github:
-
+
{% for estimation_session in estimation_sessions %}
+
+
+
+

Estimation Session For Card #12345

+
+
blargh
+
+
+
+{% endblock %} diff --git a/estimation/app/templates/select_issue.html b/estimation/app/templates/select_issue.html index e69de29..f811371 100644 --- a/estimation/app/templates/select_issue.html +++ b/estimation/app/templates/select_issue.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %} Select Isuse {% endblock %} + + +{% block content %} +
+
+
+
+

Select issue to estimate

+
+
+ {% csrf_token %} +
+
+ + +
+
+
+
+ +
+
+
+
+
+
+{% endblock %} diff --git a/estimation/app/urls.py b/estimation/app/urls.py index 119b50d..7d0e81f 100644 --- a/estimation/app/urls.py +++ b/estimation/app/urls.py @@ -8,4 +8,7 @@ path("github/callback/", views.github_callback, name="github_callback"), path("dashboard/", views.dashboard, name="dashboard"), path("logout", views.logout, name="logout"), + path("select_issue", views.select_issue, name="select_issue"), + path("confirm_issue", views.confirm_issue, name="confirm_issue"), + path("estimation_session", views.estimation_session, name="estimation_session"), ] diff --git a/estimation/app/view_models/__init__.py b/estimation/app/view_models/__init__.py index 2738c5b..b83f6c0 100644 --- a/estimation/app/view_models/__init__.py +++ b/estimation/app/view_models/__init__.py @@ -1,3 +1,5 @@ from .base_view_model import * from .dashboard_view_model import * from .index_view_model import * +from .select_issue_view_model import * +from .confirm_issue_view_model import * diff --git a/estimation/app/view_models/confirm_issue_view_model.py b/estimation/app/view_models/confirm_issue_view_model.py new file mode 100644 index 0000000..18a8775 --- /dev/null +++ b/estimation/app/view_models/confirm_issue_view_model.py @@ -0,0 +1,7 @@ +from ..models import GithubIssue +from ..view_models.base_view_model import BaseViewModel + + +class ConfirmIssueViewModel(BaseViewModel): + issue: GithubIssue + issue_url: str diff --git a/estimation/app/view_models/select_issue_view_model.py b/estimation/app/view_models/select_issue_view_model.py new file mode 100644 index 0000000..7e3d763 --- /dev/null +++ b/estimation/app/view_models/select_issue_view_model.py @@ -0,0 +1,5 @@ +from ..view_models.base_view_model import BaseViewModel + + +class SelectIssueViewModel(BaseViewModel): + issue_url: str diff --git a/estimation/app/views/__init__.py b/estimation/app/views/__init__.py index 1581478..caf4f99 100644 --- a/estimation/app/views/__init__.py +++ b/estimation/app/views/__init__.py @@ -1,2 +1,5 @@ from .base import * from .logout import * +from .select_issue import * +from .confirm_issue import * +from .estimation_session import * diff --git a/estimation/app/views/confirm_issue.py b/estimation/app/views/confirm_issue.py new file mode 100644 index 0000000..4c5316b --- /dev/null +++ b/estimation/app/views/confirm_issue.py @@ -0,0 +1,19 @@ +from django.http import HttpRequest, HttpResponseRedirect +from django.shortcuts import render + +from ..models import GithubIssue +from ..view_models.confirm_issue_view_model import ConfirmIssueViewModel + + +def confirm_issue(request: HttpRequest): + + if request.method == "POST": + # Here we'll create the database stuff + return HttpResponseRedirect("estimation_session") + + issue = GithubIssue(org="bcgov", repo="repo", issue_id=12345) + return render( + request, + "confirm_issue.html", + ConfirmIssueViewModel(issue=issue, issue_url=issue.url()), + ) diff --git a/estimation/app/views/estimation_session.py b/estimation/app/views/estimation_session.py new file mode 100644 index 0000000..92b4b6e --- /dev/null +++ b/estimation/app/views/estimation_session.py @@ -0,0 +1,6 @@ +from django.http import HttpRequest +from django.shortcuts import render + + +def estimation_session(request: HttpRequest): + return render(request, "estimation_session.html", {}) diff --git a/estimation/app/views/select_issue.py b/estimation/app/views/select_issue.py new file mode 100644 index 0000000..1a490f5 --- /dev/null +++ b/estimation/app/views/select_issue.py @@ -0,0 +1,24 @@ +from django.http import HttpRequest +from django.shortcuts import render + +from ..models import GithubIssue +from ..view_models.confirm_issue_view_model import ConfirmIssueViewModel + +from ..view_models.select_issue_view_model import SelectIssueViewModel + + +def select_issue(request: HttpRequest): + + if request.method == "POST": + issue_url = request.POST.get("issue_url") + # Here goes the Github API request + + gh_issue = GithubIssue(org="bcgov", repo="cas-estimation-tool", issue_id="1234") + + return render( + request, + "confirm_issue.html", + ConfirmIssueViewModel(issue=gh_issue, issue_url=issue_url), + ) + else: + return render(request, "select_issue.html", SelectIssueViewModel())