diff --git a/commcare_connect/opportunity/views.py b/commcare_connect/opportunity/views.py index 35cee88b..86ddb01d 100644 --- a/commcare_connect/opportunity/views.py +++ b/commcare_connect/opportunity/views.py @@ -285,11 +285,13 @@ def get(self, request, *args, **kwargs): context = self.get_context_data(object=self.object) return self.render_to_response(context) - def get_context_data(self, **kwargs): + def get_context_data(self, object, **kwargs): context = super().get_context_data(**kwargs) context["export_task_id"] = self.request.GET.get("export_task_id") context["visit_export_form"] = VisitExportForm() context["export_form"] = PaymentExportForm() + context["user_is_program_manager"] = object.managed and self.request.org_membership.is_program_manager + context["user_is_network_manager"] = object.managed and object.organization == self.request.org return context diff --git a/commcare_connect/organization/models.py b/commcare_connect/organization/models.py index 0b53eb88..bc013e03 100644 --- a/commcare_connect/organization/models.py +++ b/commcare_connect/organization/models.py @@ -53,6 +53,10 @@ def is_admin(self): def is_viewer(self): return self.role == self.Role.VIEWER + @property + def is_program_manager(self): + return self.organization.program_manager and self.is_admin + class Meta: db_table = "organization_membership" unique_together = ("user", "organization") diff --git a/commcare_connect/templates/opportunity/opportunity_detail.html b/commcare_connect/templates/opportunity/opportunity_detail.html index cd189b1b..12d1201a 100644 --- a/commcare_connect/templates/opportunity/opportunity_detail.html +++ b/commcare_connect/templates/opportunity/opportunity_detail.html @@ -22,7 +22,7 @@