From a957fa0d23cb1d7b85239819ada628c9498e4451 Mon Sep 17 00:00:00 2001 From: Pawan Verma Date: Wed, 27 Sep 2023 18:20:33 +0530 Subject: [PATCH] Add user status table to opportunity detail --- commcare_connect/opportunity/tables.py | 8 ++++++++ commcare_connect/opportunity/urls.py | 2 ++ commcare_connect/opportunity/views.py | 14 +++++++++++++- .../templates/opportunity/opportunity_detail.html | 11 +++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/commcare_connect/opportunity/tables.py b/commcare_connect/opportunity/tables.py index 5762ac97..c1b5928b 100644 --- a/commcare_connect/opportunity/tables.py +++ b/commcare_connect/opportunity/tables.py @@ -45,3 +45,11 @@ class Meta: ) empty_text = "No forms." orderable = False + + +class UserStatusTable(tables.Table): + class Meta: + model = OpportunityAccess + fields = ("user.username", "accepted") + empty_text = "No users invited for this opportunity." + orderable = False diff --git a/commcare_connect/opportunity/urls.py b/commcare_connect/opportunity/urls.py index c60a312e..521ac929 100644 --- a/commcare_connect/opportunity/urls.py +++ b/commcare_connect/opportunity/urls.py @@ -6,6 +6,7 @@ OpportunityEdit, OpportunityList, OpportunityUserLearnProgress, + OpportunityUserStatusTableView, OpportunityUserTableView, OpportunityUserVisitTableView, add_budget_existing_users, @@ -23,6 +24,7 @@ path("/", view=OpportunityDetail.as_view(), name="detail"), path("/user_table/", view=OpportunityUserTableView.as_view(), name="user_table"), path("/visit_table/", view=OpportunityUserVisitTableView.as_view(), name="visit_table"), + path("/user_status_table/", view=OpportunityUserStatusTableView.as_view(), name="user_status_table"), path("/visit_export/", view=export_user_visits, name="visit_export"), path("visit_export_status/", view=visit_export_status, name="visit_export_status"), path("download_visit_export/", view=download_visit_export, name="download_visit_export"), diff --git a/commcare_connect/opportunity/views.py b/commcare_connect/opportunity/views.py index b2d645af..7d2a1e19 100644 --- a/commcare_connect/opportunity/views.py +++ b/commcare_connect/opportunity/views.py @@ -28,7 +28,7 @@ OpportunityClaim, UserVisit, ) -from commcare_connect.opportunity.tables import OpportunityAccessTable, UserVisitTable +from commcare_connect.opportunity.tables import OpportunityAccessTable, UserStatusTable, UserVisitTable from commcare_connect.opportunity.tasks import ( add_connect_users, create_learn_modules_assessments, @@ -249,3 +249,15 @@ def add_budget_existing_users(request, org_slug=None, pk=None): "opportunity/add_visits_existing_users.html", {"form": form, "opportunity_claims": opportunity_claims, "budget_per_visit": opportunity.budget_per_visit}, ) + + +class OpportunityUserStatusTableView(OrganizationUserMixin, SingleTableView): + model = OpportunityAccess + paginate_by = 25 + table_class = UserStatusTable + template_name = "tables/single_table.html" + + def get_queryset(self): + opportunity_id = self.kwargs["pk"] + opportunity = get_object_or_404(Opportunity, organization=self.request.org, id=opportunity_id) + return OpportunityAccess.objects.filter(opportunity=opportunity).order_by("user__name") diff --git a/commcare_connect/templates/opportunity/opportunity_detail.html b/commcare_connect/templates/opportunity/opportunity_detail.html index d5c4bb3d..c5e278ee 100644 --- a/commcare_connect/templates/opportunity/opportunity_detail.html +++ b/commcare_connect/templates/opportunity/opportunity_detail.html @@ -137,6 +137,11 @@

Learn App Modules

type="button" role="tab" aria-controls="deliver-tab-pane" aria-selected="false">Deliver Forms +
Learn App Modules {% include "tables/table_placeholder.html" with num_cols=4 %}
+
+
+ {% include "tables/table_placeholder.html" with num_cols=4 %} +
+