Skip to content

Commit c8d14ab

Browse files
refactor: don't make committer permissions configurable
It is not used in practice.
1 parent 1a3a550 commit c8d14ab

File tree

7 files changed

+12
-25
lines changed

7 files changed

+12
-25
lines changed

infra/production.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ in
9595
GH_SECURITY_TEAM = "security";
9696
GH_COMMITTERS_TEAM = "nixpkgs-committers";
9797
GH_ISSUES_LABELS = [ "1.severity: security" ];
98-
GH_ISSUES_COMMITTERS_ONLY = true;
9998
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend";
10099
EMAIL_HOST = "umbriel.nixos.org";
101100
EMAIL_PORT = 465;

src/project/settings.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,6 @@ class DjangoSettings(BaseModel):
121121
This is used as a safety measure during development. Set to True in production.
122122
"""
123123
)
124-
GH_ISSUES_COMMITTERS_ONLY: bool = Field(
125-
description="""
126-
When set to True, only committers and admins can publish
127-
suggestions to create GitHub issues. This also affects who can
128-
create suggestions and add/remove maintainers.
129-
Setting this to False, will also allow maintainers to create issues.
130-
""",
131-
default=True,
132-
)
133124
GH_ORGANIZATION: str = Field(
134125
description="""
135126
The GitHub organisation from which to get team membership.

src/shared/auth/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,5 @@ def ismaintainer(user: Any) -> bool:
2020
).exists()
2121

2222

23-
def can_publish_github_issue(user: Any) -> bool:
24-
return (
25-
isadmin(user)
26-
or iscommitter(user)
27-
or (not settings.GH_ISSUES_COMMITTERS_ONLY and ismaintainer(user))
28-
)
23+
def can_edit_suggestion(user: Any) -> bool:
24+
return isadmin(user) or iscommitter(user)

src/webview/suggestions/views/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.urls import resolve
88
from django.views.generic import TemplateView
99

10-
from shared.auth import can_publish_github_issue
10+
from shared.auth import can_edit_suggestion
1111
from shared.models.linkage import (
1212
CVEDerivationClusterProposal,
1313
)
@@ -106,12 +106,13 @@ def __init__(self, response: HttpResponse) -> None:
106106
def _check_access_rights_and_get_suggestion(
107107
self, request: HttpRequest, suggestion_id: int
108108
) -> tuple[CVEDerivationClusterProposal, SuggestionContext]:
109-
if not request.user or not can_publish_github_issue(request.user):
109+
can_edit = can_edit_suggestion(self.request.user)
110+
111+
if not request.user or not can_edit:
110112
raise self.ForbiddenOperationError(HttpResponseForbidden())
111113

112114
# Get suggestion context
113115
suggestion = fetch_suggestion(suggestion_id)
114-
can_edit = can_publish_github_issue(self.request.user)
115116
suggestion_context = get_suggestion_context(suggestion, can_edit=can_edit)
116117

117118
# Validate that the suggestion status allows package editing

src/webview/suggestions/views/detail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.urls import reverse
66
from django.views.generic import DetailView, View
77

8-
from shared.auth import can_publish_github_issue
8+
from shared.auth import can_edit_suggestion
99
from shared.models.issue import NixpkgsIssue
1010
from shared.models.linkage import (
1111
CVEDerivationClusterProposal,
@@ -21,7 +21,7 @@ class SuggestionDetailView(DetailView):
2121

2222
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
2323
context = super().get_context_data(**kwargs)
24-
can_edit = can_publish_github_issue(self.request.user)
24+
can_edit = can_edit_suggestion(self.request.user)
2525
context.update(
2626
{
2727
"suggestion_context": get_suggestion_context(

src/webview/suggestions/views/lists.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.http import Http404
88
from django.views.generic import ListView
99

10-
from shared.auth import can_publish_github_issue
10+
from shared.auth import can_edit_suggestion
1111
from shared.models.linkage import (
1212
CVEDerivationClusterProposal,
1313
)
@@ -61,7 +61,7 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
6161

6262
# Convert suggestions to SuggestionContext objects for the current page
6363
suggestion_contexts = []
64-
can_edit = can_publish_github_issue(self.request.user)
64+
can_edit = can_edit_suggestion(self.request.user)
6565
# FIXME(@fricklerhandwerk): This is very slow (scales with number of events in the activity log), it should batch all related queries and do the wiring in Python.
6666
for suggestion in page_obj.object_list:
6767
suggestion_context = get_suggestion_context(suggestion, can_edit=can_edit)

src/webview/suggestions/views/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
33
from django.urls import reverse
44

5-
from shared.auth import can_publish_github_issue
5+
from shared.auth import can_edit_suggestion
66
from shared.github import create_gh_issue
77
from shared.models import (
88
NixpkgsIssue,
@@ -29,7 +29,7 @@ class UpdateSuggestionStatusView(SuggestionBaseView):
2929

3030
def post(self, request: HttpRequest, suggestion_id: int) -> HttpResponse:
3131
"""Handle status change requests."""
32-
can_edit = can_publish_github_issue(request.user)
32+
can_edit = can_edit_suggestion(request.user)
3333
if not request.user or not can_edit:
3434
return HttpResponseForbidden()
3535

0 commit comments

Comments
 (0)