Skip to content

Program Manager Permission Issue #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

hemant10yadav
Copy link
Contributor

@hemant10yadav hemant10yadav commented Mar 27, 2025

Product Description

We had a security issue where an NM organization was also a PM organization in another program. Our current code allowed the NM organization to access all PM functionalities in an opportunity where it was only an NM. This PR fixes that issue.

Technical Summary

CCCT-880

Safety Assurance

Safety story

Tested the views on local.

Automated test coverage

All previous tests are passing

QA Plan

Raised a ticket for QA

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@hemant10yadav hemant10yadav self-assigned this Mar 27, 2025
@hemant10yadav hemant10yadav marked this pull request as draft March 27, 2025 07:55
@hemant10yadav hemant10yadav marked this pull request as ready for review March 27, 2025 08:05
Copy link
Contributor

@pxwxnvermx pxwxnvermx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments related to the filter. We can reduce the number of times the filter is called by evaluating the permissions once in the views and then passing the value down through the view context.

@@ -19,7 +20,7 @@
{% block content %}
<h2>Invoices</h2>
<hr />
{% if not request.org_membership.is_program_manager %}
{% if not request|is_program_manager_for_opportunity:opportunity.id %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we evaluate this function once in the view and pass this down through the context to use on this page? This will reduce the number of times this function is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, and I partially agree. However, the main reason I implemented this as a template filter was to avoid explicitly passing the value from the view. This allows it to be accessed directly within the template when needed. Additionally, I think calling this function shouldn’t have a performance impact since the request object properties are already pre-cached—or do you see any potential concerns in this regard?

@@ -52,7 +53,7 @@ <h1 class="mb-0">{{ object.name }}</h1>
{% translate "Review User Visits" %}
</a>
</li>
{% if request.org_membership.is_program_manager or request.user.is_superuser %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@@ -21,7 +22,7 @@ <h2 class="mb-2">User Visit Review</h2>
<form method="get" x-data="" x-ref="reviewFilterForm">
{% crispy review_filter.form %}
</form>
{% if request.org_membership.is_admin and request.org.program_manager %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@@ -145,7 +146,7 @@ <h2 class="mb-2">Images</h2>
</dl>
{% endif %}
<div id="action-buttons" style="margin-bottom: 25px;">
{% if request.org_membership.is_admin and request.org.program_manager or request.org_membership.is_viewer %}
{% if request.org_membership.is_admin and request|is_program_manager_for_opportunity:visit.opportunity.id or request.org_membership.is_viewer %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants