Skip to content

Commit

Permalink
♻ Fixed a few oversights for PR
Browse files Browse the repository at this point in the history
- Fixed the language of a string
- Check that an user is not anonymous (not logged in)
  • Loading branch information
Lugrim committed Oct 14, 2023
1 parent 0b700a1 commit 1959d7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion insalan/tournament/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down
9 changes: 7 additions & 2 deletions insalan/tournament/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion insalan/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1959d7a

Please sign in to comment.