Skip to content

Commit

Permalink
Merge branch 'pkv/network-manager-view' into pkv/staging-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
pxwxnvermx committed Sep 2, 2024
2 parents 8f8aa88 + 77209bd commit 625054d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion commcare_connect/opportunity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 4 additions & 0 deletions commcare_connect/organization/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 class="mb-0">{{ object.name }}</h1>
<i class="bi bi-three-dots-vertical"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="opportunity_details_dropdown">
{% if object.managed and request.org == object.organization %}
{% if user_is_network_manager %}
<li>
<a class="dropdown-item"
href="{% url 'opportunity:user_invite' org_slug=request.org.slug pk=opportunity.id %}">
Expand Down Expand Up @@ -86,7 +86,7 @@ <h1 class="mb-0">{{ object.name }}</h1>
</a>
</li>
{% endif %}
{% if not object.managed or request.org != object.organization %}
{% if not object.managed or user_is_program_manager %}
<li>
<a class="dropdown-item"
href="{% url 'opportunity:verification_flags_config' org_slug=request.org.slug pk=opportunity.id %}">
Expand Down

0 comments on commit 625054d

Please sign in to comment.