diff --git a/README.md b/README.md index 5bdb7055..2bf108fe 100644 --- a/README.md +++ b/README.md @@ -118,10 +118,3 @@ You can leave the default values for development. You can create the tag via GitHub releases tab. 4. Ask maintainer (@ArtemSBulgakov) to allow the deployment via GitHub Actions. 5. Verify that changes work on the production server. - -### Changing JS or CSS - -When changing JS scripts or CSS styles, -you also should update 'JS_VERSION' setting in `adminpage/adminpage/settings.py`. -This is needed to update the cache in browsers. - diff --git a/adminpage/adminpage/settings.py b/adminpage/adminpage/settings.py index c90e2041..e5a2ddd7 100644 --- a/adminpage/adminpage/settings.py +++ b/adminpage/adminpage/settings.py @@ -49,8 +49,6 @@ def compose_base_url(schema, hostname, port) -> str: # People with passed checkup are able to upload self-sport SELFSPORT_MINIMUM_MEDICAL_GROUP_ID = -1 -JS_VERSION = "F24.22.22" - SPORT_DEPARTMENT_EMAIL = "sport@innopolis.university" STUDENT_AUTH_GROUP_VERBOSE_NAME = "Students" STUDENT_AUTH_GROUP_NAME = "S-1-5-21-721043115-644155662-3522934251-2285" @@ -166,7 +164,6 @@ def compose_base_url(schema, hostname, port) -> str: 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'sport.context_processors.js_version', ], }, }, @@ -292,7 +289,7 @@ def compose_base_url(schema, hostname, port) -> str: USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ STATIC_ROOT = '/static/' @@ -301,6 +298,16 @@ def compose_base_url(schema, hostname, port) -> str: else: STATIC_URL = '/static/' +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + # Add md5 hash to filenames in production + "BACKEND": "adminpage.storage.CustomManifestStaticFilesStorage", + }, +} + MEDIA_URL = '/media/' MEDIA_ROOT = '/uploaded_media' diff --git a/adminpage/adminpage/storage.py b/adminpage/adminpage/storage.py new file mode 100644 index 00000000..21c3bbec --- /dev/null +++ b/adminpage/adminpage/storage.py @@ -0,0 +1,8 @@ +from django.contrib.staticfiles.storage import ManifestStaticFilesStorage + + +class CustomManifestStaticFilesStorage(ManifestStaticFilesStorage): + def url(self, name, force=False): + if name == "plupload": + return None # Fix error with smartfields + return super().url(name, force) diff --git a/adminpage/sport/context_processors.py b/adminpage/sport/context_processors.py deleted file mode 100644 index 9464fd93..00000000 --- a/adminpage/sport/context_processors.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.conf import settings - - -def js_version(request): - return {'JS_VERSION': settings.JS_VERSION} \ No newline at end of file diff --git a/adminpage/sport/templates/base.html b/adminpage/sport/templates/base.html index 709cfccd..73e1b8f6 100644 --- a/adminpage/sport/templates/base.html +++ b/adminpage/sport/templates/base.html @@ -5,8 +5,8 @@