Flake8 (including one breakage)

See #161
This commit is contained in:
Klaas van Schelven
2025-08-28 14:40:24 +02:00
parent 31fdf46a10
commit a3cdeb9c8a
6 changed files with 13 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
from django.http import Http404
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.utils.translation import gettext_lazy as _
from bugsink.decorators import atomic_for_request_method

View File

@@ -16,7 +16,8 @@ User = get_user_model()
class ProjectMemberInviteForm(forms.Form):
email = forms.EmailField(label=_('Email'), required=True)
role = forms.ChoiceField(
label=_('Role'), choices=ProjectRole.choices, required=True, initial=ProjectRole.MEMBER, widget=forms.RadioSelect)
label=_('Role'), choices=ProjectRole.choices, required=True, initial=ProjectRole.MEMBER,
widget=forms.RadioSelect)
def __init__(self, user_must_exist, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -50,7 +51,6 @@ class MyProjectMembershipForm(forms.ModelForm):
if not edit_role:
del self.fields['role']
try:
tm = TeamMembership.objects.get(team=self.instance.project.team, user=self.instance.user)
if tm.send_email_alerts is not None:
@@ -100,7 +100,8 @@ class ProjectForm(forms.ModelForm):
self.fields["dsn"].initial = self.instance.dsn
self.fields["dsn"].label = _("DSN (read-only)")
href = reverse('project_sdk_setup', kwargs={'project_pk': self.instance.pk})
self.fields["dsn"].help_text = _("Use the DSN to <a href=\"%s\" class=\"text-cyan-800 font-bold\">set up the SDK</a>.") % href
self.fields["dsn"].help_text = _(
"Use the DSN to <a href=\"%s\" class=\"text-cyan-800 font-bold\">set up the SDK</a>.") % href
# if we ever push slug to the form, editing it should probably be disallowed as well (but mainly because it
# has consequences on the issue's short identifier)
@@ -112,7 +113,9 @@ class ProjectForm(forms.ModelForm):
self.fields["team"].queryset = team_qs
if team_qs.count() == 0:
href = reverse("team_new")
self.fields["team"].help_text = _('You don\'t have any teams yet; <a href="%s" class="text-cyan-800 font-bold">Create a team first.</a>') % href
self.fields["team"].help_text = _(
'You don\'t have any teams yet; '
'<a href="%s" class="text-cyan-800 font-bold">Create a team first.</a>') % href
elif team_qs.count() == 1:
self.fields["team"].initial = team_qs.first()

View File

@@ -53,7 +53,7 @@ class ProjectRole(models.IntegerChoices):
class ProjectVisibility(models.IntegerChoices):
# PUBLIC = 0 # anyone can see the project and its members; not sure if I want this or always require click-in
JOINABLE = 1, _("Joinable") # anyone can join
JOINABLE = 1, _("Joinable") # anyone can join
# the project's existance is visible, but the project itself is not. the idea would be that you can "request to
# join" (which is currently not implemented as a button, but you could do it 'out of bands' i.e. via email or chat).

View File

@@ -5,6 +5,7 @@ from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
class TeamRole(models.IntegerChoices):
MEMBER = 0, _("Member")
ADMIN = 1, _("Admin")

View File

@@ -127,7 +127,8 @@ def team_edit(request, team_pk):
if action == 'delete':
# Double-check that the user is an admin or superuser
if not (TeamMembership.objects.filter(team=team, user=request.user, role=TeamRole.ADMIN, accepted=True).exists() or
if not (TeamMembership.objects.filter(
team=team, user=request.user, role=TeamRole.ADMIN, accepted=True).exists() or
request.user.is_superuser):
raise PermissionDenied("Only team admins can delete teams")

View File

@@ -5,6 +5,7 @@ from django.contrib.auth.models import AbstractUser
from django.conf import settings
from django.utils.translation import gettext_lazy as _
class User(AbstractUser):
# > If youre starting a new project, its highly recommended to set up a custom user model, even if the default
# > User model is sufficient for you. This model behaves identically to the default user model, but youll be able