diff --git a/core/admin.py b/core/admin.py index 34f2be6c..74b499a6 100644 --- a/core/admin.py +++ b/core/admin.py @@ -145,7 +145,7 @@ class OrderProductInline(TabularInline): is_navtab = True verbose_name = _("order product") verbose_name_plural = _("order products") - icon = "fa-regular fa-circle-dot" + icon = "fa-solid fa-boxes-packing" def get_queryset(self, request): return ( @@ -164,7 +164,7 @@ class CategoryChildrenInline(TabularInline): is_navtab = True verbose_name = _("children") verbose_name_plural = _("children") - icon = "fa-regular fa-circle-dot" + icon = "fa-solid fa-leaf" @admin.register(AttributeGroup) diff --git a/vibes_auth/managers.py b/vibes_auth/managers.py index 04f6f6c4..67a864c4 100644 --- a/vibes_auth/managers.py +++ b/vibes_auth/managers.py @@ -39,58 +39,58 @@ class UserManager(BaseUserManager): logger.error(e) logger.error(traceback.format_exc()) - # noinspection PyUnusedLocal - def _create_user(self, email, password, **extra_fields): - email = self.normalize_email(email) - # noinspection PyShadowingNames - user = self.model(email=email, **extra_fields) - user.password = make_password(password) - user.save(using=self._db) - self.handle_unregistered_entities(user) - return user + # noinspection PyUnusedLocal + def _create_user(self, email, password, **extra_fields): + email = self.normalize_email(email) + # noinspection PyShadowingNames + user = self.model(email=email, **extra_fields) + user.password = make_password(password) + user.save(using=self._db) + self.handle_unregistered_entities(user) + return user - # noinspection PyUnusedLocal - def create_user(self, email=None, password=None, **extra_fields): - extra_fields.setdefault("is_staff", False) - extra_fields.setdefault("is_superuser", False) - return self._create_user(email, password, **extra_fields) + # noinspection PyUnusedLocal + def create_user(self, email=None, password=None, **extra_fields): + extra_fields.setdefault("is_staff", False) + extra_fields.setdefault("is_superuser", False) + return self._create_user(email, password, **extra_fields) - # noinspection PyUnusedLocal - def create_superuser(self, email=None, password=None, **extra_fields): - extra_fields.setdefault("is_staff", True) - extra_fields.setdefault("is_superuser", True) - if not extra_fields.get("is_staff"): - raise ValueError("Superuser must have is_staff=True.") - if not extra_fields.get("is_superuser"): - raise ValueError("Superuser must have is_superuser=True.") - # noinspection PyShadowingNames - user = self._create_user(email, password, **extra_fields) - user.is_active = True - user.is_verified = True - user.save() - return user + # noinspection PyUnusedLocal + def create_superuser(self, email=None, password=None, **extra_fields): + extra_fields.setdefault("is_staff", True) + extra_fields.setdefault("is_superuser", True) + if not extra_fields.get("is_staff"): + raise ValueError("Superuser must have is_staff=True.") + if not extra_fields.get("is_superuser"): + raise ValueError("Superuser must have is_superuser=True.") + # noinspection PyShadowingNames + user = self._create_user(email, password, **extra_fields) + user.is_active = True + user.is_verified = True + user.save() + return user - # noinspection PyUnusedLocal - def with_perm(self, perm, is_active=True, include_superusers=True, backend=None, obj=None): - if backend is None: - # noinspection PyCallingNonCallable - backends = auth._get_backends(return_tuples=True) - if len(backends) == 1: - backend, _ = backends[0] - else: - raise ValueError( - "You have multiple authentication backends configured and " - "therefore must provide the `backend` argument." - ) - elif not isinstance(backend, str): - raise TypeError(f"backend must be a dotted import path string (got {backend}).") + # noinspection PyUnusedLocal + def with_perm(self, perm, is_active=True, include_superusers=True, backend=None, obj=None): + if backend is None: + # noinspection PyCallingNonCallable + backends = auth._get_backends(return_tuples=True) + if len(backends) == 1: + backend, _ = backends[0] else: - backend = auth.load_backend(backend) - if hasattr(backend, "with_perm"): - return backend.with_perm( - perm, - is_active=is_active, - include_superusers=include_superusers, - obj=obj, + raise ValueError( + "You have multiple authentication backends configured and " + "therefore must provide the `backend` argument." ) - return self.none() + elif not isinstance(backend, str): + raise TypeError(f"backend must be a dotted import path string (got {backend}).") + else: + backend = auth.load_backend(backend) + if hasattr(backend, "with_perm"): + return backend.with_perm( + perm, + is_active=is_active, + include_superusers=include_superusers, + obj=obj, + ) + return self.none()