VNOI-Admin / OJ

A modern open-source online judge and contest platform system.
https://oj.vnoi.info
GNU Affero General Public License v3.0
153 stars 67 forks source link

Fix the collectstatic bug when ManifestStaticFilesStorage is enabled #397

Closed magnified103 closed 2 months ago

magnified103 commented 2 months ago

Description

Type of change: bug fix

Why

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'

python manage.py collectstatic failed:

 File "/usr/local/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py", line 288, in _post_process
    content = pattern.sub(converter, content)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py", line 187, in converter
    hashed_url = self._url(
                 ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py", line 126, in _url
    hashed_name = hashed_name_func(*args)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py", line 338, in _stored_name
    cache_name = self.clean_name(self.hashed_name(name))
                                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py", line 88, in hashed_name
    raise ValueError("The file '%s' could not be found with %r." % (filename, self))
ValueError: The file 'vnoj/jquery-ui/images/ui-icons_444444_256x240.png' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7fda708ed010>.

The sole reason is that jquery-ui.min.css references some external (but irrelevant) media (e.g. images/ui-icons_444444_256x240.png) which triggers errors on ManifestStaticFilesStorage post-processing.

This PR prunes the css part of jquery-ui (theme.css is no longer included). The jquery-ui version is also bumped from 1.13.2 to 1.13.3.

How Has This Been Tested?

Tested locally. These changes should not bring any regression.

By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.