Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations and linting #58

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion insalan/user/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class UserConfig(AppConfig):
"""Configuration of the User Django App"""

name = "insalan.user"
verbose_name = _("Gestionnaire d'utilisateur⋅ices")
verbose_name = _("Gestionnaire d'utilisateur⋅rices")
default_auto_field = "django.db.models.BigAutoField"
18 changes: 11 additions & 7 deletions insalan/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def create_user(
check that all required fields are present and create an user
"""
if not email:
raise ValueError(_("An email is required"))
raise ValueError(_("Un courriel est requis"))
if not username:
raise ValueError(_("An username is required"))
raise ValueError(_("Un nom d'utilisateur·rice est requis"))
Lugrim marked this conversation as resolved.
Show resolved Hide resolved
if not password:
raise ValueError(_("A password is required"))
raise ValueError(_("Un mot de passe est requis"))
user = self.model(
email=self.normalize_email(email),
username=username,
Expand All @@ -47,8 +47,11 @@ def create_user(
return user

def create_superuser(self, email, username, password, **extra_fields):
"""
Check that all required fields are present and create a superuser
"""
if password is None:
raise TypeError("Superusers must have a password.")
raise TypeError(_("Les superutilisateur·rices requièrent un mot de passe"))
user = self.create_user(email, username, password, **extra_fields)
user.is_superuser = True
user.is_staff = True
Expand All @@ -68,7 +71,7 @@ class User(AbstractUser, PermissionsMixin):
class Meta:
"""Meta options"""

verbose_name = _("Utilisateur⋅ice")
verbose_name = _("Utilisateur⋅rice")
verbose_name_plural = _("Utilisateur⋅ices")

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -122,8 +125,8 @@ def send_email_confirmation(user_object: User):
user = user_object.username
# TODO Give a frontend page instead of direct API link
send_mail(
_("Confirmez votre e-mail"),
_("Confirmez votre adresse e-mail en cliquant sur ")
_("Confirmez votre courriel"),
_("Confirmez votre adresse de courriel en cliquant sur ")
+ "http://api."
+ getenv("WEBSITE_HOST", "localhost")
+ reverse("confirm-email", kwargs={"user": user, "token": token}),
Expand All @@ -132,6 +135,7 @@ def send_email_confirmation(user_object: User):
fail_silently=False,
)

@staticmethod
def send_password_reset(user_object: User):
"""
Send a password reset token.
Expand Down
2 changes: 1 addition & 1 deletion insalan/user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_validity(self, data):
user = authenticate(username=data["username"], password=data["password"])
if user is not None:
if not user.is_active or not user.email_active:
raise serializers.ValidationError(_("Account not actived"))
raise serializers.ValidationError(_("Compte non activé"))
return user


Expand Down
Loading
Loading