mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +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:
|
||||
"""
|
||||
|
||||
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:
|
||||
Path(f"{settings.STATIC_ROOT}allianceauth/custom-styles.css").resolve(strict=True)
|
||||
Path(f"{settings.STATIC_ROOT}{path}").resolve(strict=True)
|
||||
except FileNotFoundError:
|
||||
return ""
|
||||
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
|
||||
|
||||
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')
|
||||
|
Loading…
x
Reference in New Issue
Block a user