Skip to content

[FIX] Grant maintainer privileges to superuser and fix attention set handling #7

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 4 commits into
base: i507
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions patchwork/api/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,16 @@ def partial_update(self, request, *args, **kwargs):
req_user_id = request.user.id
is_maintainer = request.user.is_authenticated and (
obj.project in request.user.profile.maintainer_projects.all()
or request.user.is_superuser
)
non_attention_set_keys = [
key for key in request.data if key != 'attention_set'
]

if non_attention_set_keys and not is_maintainer:
raise PermissionDenied(
detail='You do not have permission to edit patch properties.'
)

if 'attention_set' in request.data and request.method in ('PATCH',):
attention_set = request.data.get('attention_set', None)
Expand Down
2 changes: 1 addition & 1 deletion patchwork/templatetags/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def patch_commit_display(patch):

@register.filter(name='patch_interest')
def patch_interest(patch):
reviews = patch.attention_set.count()
reviews = patch.patchattentionset_set.filter(removed=False).count()
review_title = (
f'has {reviews} interested reviewers'
if reviews > 0
Expand Down
5 changes: 2 additions & 3 deletions patchwork/views/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def patch_detail(request, project_id, msgid):
is_maintainer = (
request.user.is_authenticated
and project in request.user.profile.maintainer_projects.all()
or request.user.is_superuser
)

form = None
Expand All @@ -89,9 +90,7 @@ def patch_detail(request, project_id, msgid):
elif action in ['add-interest', 'remove-interest']:
if request.user.is_authenticated:
if action == 'add-interest':
PatchAttentionSet.objects.get_or_create(
patch=patch, user=request.user
)
PatchAttentionSet.objects.upsert(patch, [request.user.id])
message = (
'You have declared interest in reviewing this patch'
)
Expand Down