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
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue