mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
[CHANGE] improve try block in template tag
This commit is contained in:
parent
a8271c4189
commit
3c2c137dad
@ -28,17 +28,16 @@ def custom_css_static(path: str) -> str:
|
|||||||
:rtype:
|
:rtype:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
custom_css_changed = CustomCSS.objects.first().timestamp.timestamp()
|
|
||||||
custom_css_version = (
|
|
||||||
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
|
|
||||||
) # remove spaces, colons, and dashes
|
|
||||||
static_url = static(path)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Path(f"{settings.STATIC_ROOT}allianceauth/custom-styles.css").resolve(strict=True)
|
Path(f"{settings.STATIC_ROOT}{path}").resolve(strict=True)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
|
custom_css_changed = CustomCSS.objects.first().timestamp.timestamp()
|
||||||
|
custom_css_version = (
|
||||||
|
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
|
||||||
|
) # remove spaces, colons, and dashes
|
||||||
|
static_url = static(path)
|
||||||
versioned_url = static_url + "?v=" + custom_css_version
|
versioned_url = static_url + "?v=" + custom_css_version
|
||||||
|
|
||||||
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')
|
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user