diff --git a/insalan/tournament/tests.py b/insalan/tournament/tests.py index 9759323e..27935bf4 100644 --- a/insalan/tournament/tests.py +++ b/insalan/tournament/tests.py @@ -916,7 +916,6 @@ def test_example(self): reverse("tournament/details-full", args=[tourneyobj_one.id]), format="json" ) self.assertEqual(request.status_code, 200) - # print(request.data) self.assertEqual( request.data, { diff --git a/insalan/tournament/views.py b/insalan/tournament/views.py index 11a10ae1..e50ed0ea 100644 --- a/insalan/tournament/views.py +++ b/insalan/tournament/views.py @@ -198,7 +198,7 @@ def post(this, request, *args, **kwargs): user = request.user data = request.data - if user is None or "name" not in data: + if user is None or not user.is_authenticated or "name" not in data: raise PermissionDenied() if not user.is_email_active(): @@ -245,7 +245,12 @@ def post(this, request, *args, **kwargs): user = request.user data = request.data - if user is None or "team" not in data or "payment" in data: + if ( + user is None + or not user.is_authenticated + or "team" not in data + or "payment" in data + ): raise PermissionDenied() if not user.is_email_active(): diff --git a/insalan/user/models.py b/insalan/user/models.py index b5e4b6d2..039e75f7 100644 --- a/insalan/user/models.py +++ b/insalan/user/models.py @@ -19,6 +19,7 @@ from django.utils.translation import gettext_lazy as _ from django.core.validators import FileExtensionValidator + class UserManager(BaseUserManager): """ Managers the User objects (kind of like a serializer but not quite that) @@ -73,7 +74,7 @@ class Meta: verbose_name = _("Utilisateur⋅rice") verbose_name_plural = _("Utilisateur⋅ices") - permissions = [("email_active", "The user has activated their e-mail")] + permissions = [("email_active", _("L'utilisateur⋅ice a activé son courriel"))] def __init__(self, *args, **kwargs): AbstractUser.__init__(self, *args, **kwargs)