From 8c161e6e31a6c4baaf95053061429369f66d7f2b Mon Sep 17 00:00:00 2001 From: hemant10yadav Date: Fri, 29 Nov 2024 13:49:17 +0530 Subject: [PATCH] added the org slug in table --- commcare_connect/opportunity/tables.py | 16 +++++++++------- commcare_connect/opportunity/views.py | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/commcare_connect/opportunity/tables.py b/commcare_connect/opportunity/tables.py index a856650f..ca9586ad 100644 --- a/commcare_connect/opportunity/tables.py +++ b/commcare_connect/opportunity/tables.py @@ -374,7 +374,7 @@ class Meta: ) -class UserVisitReviewTable(tables.Table): +class UserVisitReviewTable(OrgContextTable): pk = columns.CheckBoxColumn( accessor="pk", verbose_name="", @@ -389,12 +389,7 @@ class UserVisitReviewTable(tables.Table): visit_date = columns.Column() created_on = columns.Column(accessor="review_created_on", verbose_name="Review Requested On") review_status = columns.Column(verbose_name="Program Manager Review") - user_visit = columns.LinkColumn( - "opportunity:visit_verification", - verbose_name="User Visit", - text="View", - args=[utils.A("opportunity__organization__slug"), utils.A("pk")], - ) + user_visit = columns.Column(verbose_name="User Visit", empty_values=()) class Meta: model = UserVisit @@ -412,6 +407,13 @@ class Meta: ) empty_text = "No visits submitted for review." + def render_user_visit(self, record): + url = reverse( + "opportunity:visit_verification", + kwargs={"org_slug": self.org_slug, "pk": record.pk}, + ) + return mark_safe(f'View') + class PaymentReportTable(tables.Table): payment_unit = columns.Column(verbose_name="Payment Unit") diff --git a/commcare_connect/opportunity/views.py b/commcare_connect/opportunity/views.py index a53c0050..645ba4ef 100644 --- a/commcare_connect/opportunity/views.py +++ b/commcare_connect/opportunity/views.py @@ -1112,7 +1112,7 @@ def user_visit_review(request, org_slug, opp_id): user_visit_reviews = UserVisit.objects.filter(opportunity=opportunity, review_created_on__isnull=False).order_by( "visit_date" ) - table = UserVisitReviewTable(user_visit_reviews) + table = UserVisitReviewTable(user_visit_reviews, org_slug=request.org.slug) if not is_program_manager: table.exclude = ("pk",) if request.POST and is_program_manager: