mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
|
|||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import user_passes_test
|
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
|
from bugsink.decorators import atomic_for_request_method
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ User = get_user_model()
|
|||||||
class ProjectMemberInviteForm(forms.Form):
|
class ProjectMemberInviteForm(forms.Form):
|
||||||
email = forms.EmailField(label=_('Email'), required=True)
|
email = forms.EmailField(label=_('Email'), required=True)
|
||||||
role = forms.ChoiceField(
|
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):
|
def __init__(self, user_must_exist, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@@ -50,7 +51,6 @@ class MyProjectMembershipForm(forms.ModelForm):
|
|||||||
if not edit_role:
|
if not edit_role:
|
||||||
del self.fields['role']
|
del self.fields['role']
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tm = TeamMembership.objects.get(team=self.instance.project.team, user=self.instance.user)
|
tm = TeamMembership.objects.get(team=self.instance.project.team, user=self.instance.user)
|
||||||
if tm.send_email_alerts is not None:
|
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"].initial = self.instance.dsn
|
||||||
self.fields["dsn"].label = _("DSN (read-only)")
|
self.fields["dsn"].label = _("DSN (read-only)")
|
||||||
href = reverse('project_sdk_setup', kwargs={'project_pk': self.instance.pk})
|
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
|
# 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)
|
# has consequences on the issue's short identifier)
|
||||||
@@ -112,7 +113,9 @@ class ProjectForm(forms.ModelForm):
|
|||||||
self.fields["team"].queryset = team_qs
|
self.fields["team"].queryset = team_qs
|
||||||
if team_qs.count() == 0:
|
if team_qs.count() == 0:
|
||||||
href = reverse("team_new")
|
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:
|
elif team_qs.count() == 1:
|
||||||
self.fields["team"].initial = team_qs.first()
|
self.fields["team"].initial = team_qs.first()
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ProjectRole(models.IntegerChoices):
|
|||||||
|
|
||||||
class ProjectVisibility(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
|
# 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
|
# 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).
|
# join" (which is currently not implemented as a button, but you could do it 'out of bands' i.e. via email or chat).
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from django.db import models
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class TeamRole(models.IntegerChoices):
|
class TeamRole(models.IntegerChoices):
|
||||||
MEMBER = 0, _("Member")
|
MEMBER = 0, _("Member")
|
||||||
ADMIN = 1, _("Admin")
|
ADMIN = 1, _("Admin")
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ def team_edit(request, team_pk):
|
|||||||
|
|
||||||
if action == 'delete':
|
if action == 'delete':
|
||||||
# Double-check that the user is an admin or superuser
|
# 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):
|
request.user.is_superuser):
|
||||||
raise PermissionDenied("Only team admins can delete teams")
|
raise PermissionDenied("Only team admins can delete teams")
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from django.contrib.auth.models import AbstractUser
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class User(AbstractUser):
|
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
|
# > 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
|
# > User model is sufficient for you. This model behaves identically to the default user model, but you’ll be able
|
||||||
|
|||||||
Reference in New Issue
Block a user