mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-30 15:15:24 +00:00
Better fix
This commit is contained in:
parent
41e68224ca
commit
46bc00d971
@ -185,7 +185,7 @@ def get_group(*, pk: int = None, name: str = None) -> Optional[Group]:
|
|||||||
if pk is None and name is None:
|
if pk is None and name is None:
|
||||||
raise ValueError("Either pk or name must be set")
|
raise ValueError("Either pk or name must be set")
|
||||||
|
|
||||||
pk_or_name: Union[str, int] = pk if pk is not None else name
|
pk_or_name: Union[str, int] = pk if pk is not None else name.replace(" ", "_")
|
||||||
group = cache.get(f"sith_group_{pk_or_name}")
|
group = cache.get(f"sith_group_{pk_or_name}")
|
||||||
|
|
||||||
if group == "not_found":
|
if group == "not_found":
|
||||||
@ -201,7 +201,7 @@ def get_group(*, pk: int = None, name: str = None) -> Optional[Group]:
|
|||||||
group = Group.objects.filter(name=name).first()
|
group = Group.objects.filter(name=name).first()
|
||||||
if group is not None:
|
if group is not None:
|
||||||
cache.set(f"sith_group_{group.id}", group)
|
cache.set(f"sith_group_{group.id}", group)
|
||||||
cache.set(f"sith_group_{group.name}", group)
|
cache.set(f"sith_group_{group.name.replace(' ', '_')}", group)
|
||||||
else:
|
else:
|
||||||
cache.set(f"sith_group_{pk_or_name}", "not_found")
|
cache.set(f"sith_group_{pk_or_name}", "not_found")
|
||||||
return group
|
return group
|
||||||
|
Loading…
x
Reference in New Issue
Block a user