mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
[CHANGE] Remove custom CSS file when it will be empty
This commit is contained in:
parent
3315ae7778
commit
a8271c4189
@ -3,6 +3,7 @@ Models for the custom_css app
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -61,11 +62,19 @@ class CustomCSS(SingletonModel):
|
|||||||
|
|
||||||
self.pk = 1
|
self.pk = 1
|
||||||
|
|
||||||
custom_css_file = open(
|
if len(self.css.replace(" ", "")) > 0:
|
||||||
f"{settings.STATIC_ROOT}allianceauth/custom-styles.css", "w+"
|
# Write the custom CSS to a file
|
||||||
)
|
custom_css_file = open(
|
||||||
custom_css_file.write(self.compress_css())
|
f"{settings.STATIC_ROOT}allianceauth/custom-styles.css", "w+"
|
||||||
custom_css_file.close()
|
)
|
||||||
|
custom_css_file.write(self.compress_css())
|
||||||
|
custom_css_file.close()
|
||||||
|
else:
|
||||||
|
# Remove the custom CSS file
|
||||||
|
try:
|
||||||
|
os.remove(f"{settings.STATIC_ROOT}allianceauth/custom-styles.css")
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user