diff --git a/commcare_connect/opportunity/tables.py b/commcare_connect/opportunity/tables.py
index a856650f..e361f4c0 100644
--- a/commcare_connect/opportunity/tables.py
+++ b/commcare_connect/opportunity/tables.py
@@ -153,7 +153,7 @@ class UserStatusTable(OrgContextTable):
passed_assessment = BooleanAggregateColumn(verbose_name="Passed Assessment")
started_delivery = AggregateColumn(verbose_name="Started Delivery", accessor="date_deliver_started")
last_visit_date = columns.Column(accessor="last_visit_date_d")
- view_profile = columns.Column("View Profile", empty_values=(), footer=lambda table: f"Invited: {len(table.rows)}")
+ view_profile = columns.Column("", empty_values=(), footer=lambda table: f"Invited: {len(table.rows)}")
class Meta:
model = UserInvite
@@ -173,22 +173,29 @@ class Meta:
orderable = False
def render_display_name(self, record):
- if record.opportunity_access is None:
- return record.phone_number
- if not record.opportunity_access.accepted:
+ if not getattr(record.opportunity_access, "accepted", False):
return "---"
return record.opportunity_access.display_name
def render_view_profile(self, record):
- if record.opportunity_access is None:
- return "---"
- if not record.opportunity_access.accepted:
- return "---"
+ if not getattr(record.opportunity_access, "accepted", False):
+ invite_delete_url = reverse(
+ "opportunity:user_invite_delete",
+ args=(self.org_slug, record.opportunity.id, record.id),
+ )
+ return format_html(
+ (
+ ''
+ ),
+ invite_delete_url,
+ )
url = reverse(
"opportunity:user_profile",
kwargs={"org_slug": self.org_slug, "opp_id": record.opportunity.id, "pk": record.opportunity_access_id},
)
- return format_html('View Profile', url)
+ return format_html('View Profile', url)
def render_started_learning(self, record, value):
return date_with_time_popup(self, value)
diff --git a/commcare_connect/opportunity/urls.py b/commcare_connect/opportunity/urls.py
index 66b7a957..ef5cae31 100644
--- a/commcare_connect/opportunity/urls.py
+++ b/commcare_connect/opportunity/urls.py
@@ -112,4 +112,5 @@
path("/invoice_table/", views.PaymentInvoiceTableView.as_view(), name="invoice_table"),
path("/invoice/create/", views.invoice_create, name="invoice_create"),
path("/invoice/approve/", views.invoice_approve, name="invoice_approve"),
+ path("/user_invite_delete//", views.user_invite_delete, name="user_invite_delete"),
]
diff --git a/commcare_connect/opportunity/views.py b/commcare_connect/opportunity/views.py
index e9083536..d725bbe5 100644
--- a/commcare_connect/opportunity/views.py
+++ b/commcare_connect/opportunity/views.py
@@ -64,6 +64,7 @@
Payment,
PaymentInvoice,
PaymentUnit,
+ UserInvite,
UserVisit,
VisitReviewStatus,
VisitValidationStatus,
@@ -1217,3 +1218,13 @@ def invoice_approve(request, org_slug, pk):
)
payment.save()
return HttpResponse(headers={"HX-Trigger": "newInvoice"})
+
+
+@org_member_required
+@require_POST
+@csrf_exempt
+def user_invite_delete(request, org_slug, opp_id, pk):
+ opportunity = get_opportunity_or_404(opp_id, org_slug)
+ invite = get_object_or_404(UserInvite, pk=pk, opportunity=opportunity)
+ invite.delete()
+ return HttpResponse(status=200, headers={"HX-Trigger": "userStatusReload"})
diff --git a/commcare_connect/templates/opportunity/opportunity_detail.html b/commcare_connect/templates/opportunity/opportunity_detail.html
index eeeb7dd8..b1aef96d 100644
--- a/commcare_connect/templates/opportunity/opportunity_detail.html
+++ b/commcare_connect/templates/opportunity/opportunity_detail.html
@@ -364,7 +364,7 @@