diff --git a/bsmain/views.py b/bsmain/views.py index 9352813..25be8d7 100644 --- a/bsmain/views.py +++ b/bsmain/views.py @@ -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 diff --git a/projects/forms.py b/projects/forms.py index b009a3e..7fbd460 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -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 set up the SDK.") % href + self.fields["dsn"].help_text = _( + "Use the DSN to set up the SDK.") % 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; Create a team first.') % href + self.fields["team"].help_text = _( + 'You don\'t have any teams yet; ' + 'Create a team first.') % href elif team_qs.count() == 1: self.fields["team"].initial = team_qs.first() diff --git a/projects/models.py b/projects/models.py index 7df3374..bc3c486 100644 --- a/projects/models.py +++ b/projects/models.py @@ -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). diff --git a/teams/models.py b/teams/models.py index 1cf98ec..a725846 100644 --- a/teams/models.py +++ b/teams/models.py @@ -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") diff --git a/teams/views.py b/teams/views.py index fc420e1..6a39141 100644 --- a/teams/views.py +++ b/teams/views.py @@ -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") diff --git a/users/models.py b/users/models.py index 88afc8b..afe297c 100644 --- a/users/models.py +++ b/users/models.py @@ -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 you’re starting a new project, it’s 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 you’ll be able