Skip to content
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

fix: Non-admin users cannot link a feature to a GH Issue/PR #4336

Merged

Conversation

novakzaballa
Copy link
Contributor

@novakzaballa novakzaballa commented Jul 15, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Granting a non-admin user permission to view the repositories integrated with Flagsmith allows them to link issues/PRs with features in the UI

How did you test this code?

Unit test added

@novakzaballa novakzaballa requested a review from a team as a code owner July 15, 2024 14:51
@novakzaballa novakzaballa requested review from zachaysan and removed request for a team July 15, 2024 14:51
Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 9:32pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 9:32pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 9:32pm

@github-actions github-actions bot added api Issue related to the REST API fix labels Jul 15, 2024
Copy link
Contributor

github-actions bot commented Jul 15, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-4336 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4336 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4336 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4336 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4336 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jul 15, 2024

Uffizzi Preview deployment-54199 was deleted.

Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.77%. Comparing base (b32a6ca) to head (2dc2eaf).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4336   +/-   ##
=======================================
  Coverage   96.77%   96.77%           
=======================================
  Files        1159     1159           
  Lines       38069    38079   +10     
=======================================
+ Hits        36842    36852   +10     
  Misses       1227     1227           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Jul 15, 2024
@novakzaballa novakzaballa force-pushed the fix/non-admin-users-cannot-link-a-feature-to-a-gh-issue-pr branch from 40ec824 to 2a9bcc4 Compare July 15, 2024 17:11
@github-actions github-actions bot added fix and removed fix labels Jul 15, 2024
Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

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

Some minor questions but nothing major

@@ -189,18 +189,20 @@ def has_object_permission(self, request, view, obj):


class GithubIsAdminOrganisation(NestedIsOrganisationAdminPermission):
def has_permission(self, request, view):
def has_permission(self, request, view) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def has_permission(self, request, view) -> bool:
def has_permission(self, request: Request, view: GenericViewSet) -> bool:

if isinstance(request.user, FFAdminUser):
return request.user.is_organisation_admin(
Organisation.objects.get(pk=organisation_pk)
)
else:
return request.user.is_master_api_key_user

def has_object_permission(self, request, view, obj):
def has_object_permission(self, request, view, obj) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: typing

# When
response = staff_client.get(url)
# Then
assert response.status_code == status.HTTP_200_OK
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 add additional assertions here like testing that the GitHub configuration looks like something we expect?

@github-actions github-actions bot added fix and removed fix labels Jul 15, 2024
@novakzaballa novakzaballa force-pushed the fix/non-admin-users-cannot-link-a-feature-to-a-gh-issue-pr branch from 3fa14a9 to 2dc2eaf Compare July 15, 2024 21:32
@github-actions github-actions bot added fix and removed fix labels Jul 15, 2024
@novakzaballa novakzaballa added this pull request to the merge queue Jul 16, 2024
Merged via the queue into main with commit 56e6390 Jul 16, 2024
33 checks passed
@novakzaballa novakzaballa deleted the fix/non-admin-users-cannot-link-a-feature-to-a-gh-issue-pr branch July 16, 2024 13:20
@novakzaballa novakzaballa linked an issue Jul 16, 2024 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only admins can link a feature to a GH issue/PR
2 participants