Skip to content

Commit

Permalink
Add user status table to opportunity detail
Browse files Browse the repository at this point in the history
  • Loading branch information
pxwxnvermx committed Sep 27, 2023
1 parent 8016185 commit a957fa0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions commcare_connect/opportunity/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions commcare_connect/opportunity/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
OpportunityEdit,
OpportunityList,
OpportunityUserLearnProgress,
OpportunityUserStatusTableView,
OpportunityUserTableView,
OpportunityUserVisitTableView,
add_budget_existing_users,
Expand All @@ -23,6 +24,7 @@
path("<int:pk>/", view=OpportunityDetail.as_view(), name="detail"),
path("<int:pk>/user_table/", view=OpportunityUserTableView.as_view(), name="user_table"),
path("<int:pk>/visit_table/", view=OpportunityUserVisitTableView.as_view(), name="visit_table"),
path("<int:pk>/user_status_table/", view=OpportunityUserStatusTableView.as_view(), name="user_status_table"),
path("<int:pk>/visit_export/", view=export_user_visits, name="visit_export"),
path("visit_export_status/<slug:task_id>", view=visit_export_status, name="visit_export_status"),
path("download_visit_export/<slug:task_id>", view=download_visit_export, name="download_visit_export"),
Expand Down
14 changes: 13 additions & 1 deletion commcare_connect/opportunity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
11 changes: 11 additions & 0 deletions commcare_connect/templates/opportunity/opportunity_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ <h4>Learn App Modules</h4>
type="button" role="tab" aria-controls="deliver-tab-pane" aria-selected="false">Deliver Forms
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="user-status-tab" data-bs-toggle="tab" data-bs-target="#user-status-tab-pane"
type="button" role="tab" aria-controls="user-status-tab-pane" aria-selected="false">User Status
</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="learn-tab-pane" role="tabpanel" aria-labelledby="learn-tab"
Expand All @@ -152,6 +157,12 @@ <h4>Learn App Modules</h4>
{% include "tables/table_placeholder.html" with num_cols=4 %}
</div>
</div>
<div class="tab-pane fade" id="user-status-tab-pane" role="tabpanel" aria-labelledby="user-status-tab" tabindex="0">
<div hx-get="{% url "opportunity:user_status_table" org_slug=request.org.slug pk=opportunity.pk %}{% querystring %}"
hx-trigger="load" hx-swap="outerHTML">
{% include "tables/table_placeholder.html" with num_cols=4 %}
</div>
</div>
</div>
</div>
<div class="pt-2 px-4">
Expand Down

0 comments on commit a957fa0

Please sign in to comment.