Features: 1) Update admin icons for better visual representation ("order products" and "children").
Fixes: None; Extra: 1) Normalize code formatting in `vibes_auth` manager methods for consistency; 2) Clean redundant indentation and comments in methods.
This commit is contained in:
parent
e6d59f053c
commit
426af1ad2c
2 changed files with 52 additions and 52 deletions
|
|
@ -145,7 +145,7 @@ class OrderProductInline(TabularInline):
|
||||||
is_navtab = True
|
is_navtab = True
|
||||||
verbose_name = _("order product")
|
verbose_name = _("order product")
|
||||||
verbose_name_plural = _("order products")
|
verbose_name_plural = _("order products")
|
||||||
icon = "fa-regular fa-circle-dot"
|
icon = "fa-solid fa-boxes-packing"
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
return (
|
return (
|
||||||
|
|
@ -164,7 +164,7 @@ class CategoryChildrenInline(TabularInline):
|
||||||
is_navtab = True
|
is_navtab = True
|
||||||
verbose_name = _("children")
|
verbose_name = _("children")
|
||||||
verbose_name_plural = _("children")
|
verbose_name_plural = _("children")
|
||||||
icon = "fa-regular fa-circle-dot"
|
icon = "fa-solid fa-leaf"
|
||||||
|
|
||||||
|
|
||||||
@admin.register(AttributeGroup)
|
@admin.register(AttributeGroup)
|
||||||
|
|
|
||||||
|
|
@ -39,58 +39,58 @@ class UserManager(BaseUserManager):
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def _create_user(self, email, password, **extra_fields):
|
def _create_user(self, email, password, **extra_fields):
|
||||||
email = self.normalize_email(email)
|
email = self.normalize_email(email)
|
||||||
# noinspection PyShadowingNames
|
# noinspection PyShadowingNames
|
||||||
user = self.model(email=email, **extra_fields)
|
user = self.model(email=email, **extra_fields)
|
||||||
user.password = make_password(password)
|
user.password = make_password(password)
|
||||||
user.save(using=self._db)
|
user.save(using=self._db)
|
||||||
self.handle_unregistered_entities(user)
|
self.handle_unregistered_entities(user)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def create_user(self, email=None, password=None, **extra_fields):
|
def create_user(self, email=None, password=None, **extra_fields):
|
||||||
extra_fields.setdefault("is_staff", False)
|
extra_fields.setdefault("is_staff", False)
|
||||||
extra_fields.setdefault("is_superuser", False)
|
extra_fields.setdefault("is_superuser", False)
|
||||||
return self._create_user(email, password, **extra_fields)
|
return self._create_user(email, password, **extra_fields)
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def create_superuser(self, email=None, password=None, **extra_fields):
|
def create_superuser(self, email=None, password=None, **extra_fields):
|
||||||
extra_fields.setdefault("is_staff", True)
|
extra_fields.setdefault("is_staff", True)
|
||||||
extra_fields.setdefault("is_superuser", True)
|
extra_fields.setdefault("is_superuser", True)
|
||||||
if not extra_fields.get("is_staff"):
|
if not extra_fields.get("is_staff"):
|
||||||
raise ValueError("Superuser must have is_staff=True.")
|
raise ValueError("Superuser must have is_staff=True.")
|
||||||
if not extra_fields.get("is_superuser"):
|
if not extra_fields.get("is_superuser"):
|
||||||
raise ValueError("Superuser must have is_superuser=True.")
|
raise ValueError("Superuser must have is_superuser=True.")
|
||||||
# noinspection PyShadowingNames
|
# noinspection PyShadowingNames
|
||||||
user = self._create_user(email, password, **extra_fields)
|
user = self._create_user(email, password, **extra_fields)
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.is_verified = True
|
user.is_verified = True
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def with_perm(self, perm, is_active=True, include_superusers=True, backend=None, obj=None):
|
def with_perm(self, perm, is_active=True, include_superusers=True, backend=None, obj=None):
|
||||||
if backend is None:
|
if backend is None:
|
||||||
# noinspection PyCallingNonCallable
|
# noinspection PyCallingNonCallable
|
||||||
backends = auth._get_backends(return_tuples=True)
|
backends = auth._get_backends(return_tuples=True)
|
||||||
if len(backends) == 1:
|
if len(backends) == 1:
|
||||||
backend, _ = backends[0]
|
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}).")
|
|
||||||
else:
|
else:
|
||||||
backend = auth.load_backend(backend)
|
raise ValueError(
|
||||||
if hasattr(backend, "with_perm"):
|
"You have multiple authentication backends configured and "
|
||||||
return backend.with_perm(
|
"therefore must provide the `backend` argument."
|
||||||
perm,
|
|
||||||
is_active=is_active,
|
|
||||||
include_superusers=include_superusers,
|
|
||||||
obj=obj,
|
|
||||||
)
|
)
|
||||||
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()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue