From 41e68224ca0924f9ed3e4680d96e58108e1f0f0a Mon Sep 17 00:00:00 2001 From: Julien Constant Date: Thu, 11 May 2023 16:30:01 +0200 Subject: [PATCH] Temporary solution (re-add the warning) --- core/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/models.py b/core/models.py index 8a01c2d5..6e51312d 100644 --- a/core/models.py +++ b/core/models.py @@ -180,14 +180,14 @@ def get_group(*, pk: int = None, name: str = None) -> Optional[Group]: :param pk: The primary key of the group :param name: The name of the group :return: The group if it exists, else None - :raises ValueError: If no group matches the criteria + :raise ValueError: If no group matches the criteria """ if pk is None and name is None: raise ValueError("Either pk or name must be set") - if name is not None: - name = name.replace(" ", "_") # avoid errors with memcached backend + pk_or_name: Union[str, int] = pk if pk is not None else name group = cache.get(f"sith_group_{pk_or_name}") + if group == "not_found": # Using None as a cache value is a little bit tricky, # so we use a special string to represent None @@ -201,7 +201,7 @@ def get_group(*, pk: int = None, name: str = None) -> Optional[Group]: group = Group.objects.filter(name=name).first() if group is not None: cache.set(f"sith_group_{group.id}", group) - cache.set(f"sith_group_{group.name.replace(' ', '_')}", group) + cache.set(f"sith_group_{group.name}", group) else: cache.set(f"sith_group_{pk_or_name}", "not_found") return group