Merge pull request #3804 from normanjaeckel/ChangeCollectStatic
Fixed collectstattic command so that it does not write into openslide…
This commit is contained in:
commit
96637e18c4
@ -23,14 +23,15 @@ Motions:
|
|||||||
- New table of contents with page numbers and categories in PDF [#3766].
|
- New table of contents with page numbers and categories in PDF [#3766].
|
||||||
- New teporal field "modified final version" where the final version can
|
- New teporal field "modified final version" where the final version can
|
||||||
be edited [#3781].
|
be edited [#3781].
|
||||||
- New config to show amendments also in motions table [#3792]
|
- New config to show amendments also in motions table [#3792].
|
||||||
- Support to change decimal places for polls with a plugin [#3803]
|
- Support to change decimal places for polls with a plugin [#3803].
|
||||||
|
|
||||||
Core:
|
Core:
|
||||||
- Python 3.4 is not supported anymore [#3777].
|
- Python 3.4 is not supported anymore [#3777].
|
||||||
- Support Python 3.7 [#3786].
|
- Support Python 3.7 [#3786].
|
||||||
- Updated pdfMake to 0.1.37 [#3766].
|
- Updated pdfMake to 0.1.37 [#3766].
|
||||||
- Updated Django to 2.1 [#3777, #3786].
|
- Updated Django to 2.1 [#3777, #3786].
|
||||||
|
- Changed behavior of collectstatic management command [#3804].
|
||||||
|
|
||||||
|
|
||||||
Version 2.2 (2018-06-06)
|
Version 2.2 (2018-06-06)
|
||||||
|
@ -4,6 +4,7 @@ from typing import Any, Dict
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.management.commands.collectstatic import \
|
from django.contrib.staticfiles.management.commands.collectstatic import \
|
||||||
Command as CollectStatic
|
Command as CollectStatic
|
||||||
|
from django.contrib.staticfiles.utils import matches_patterns
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
from django.db.utils import OperationalError
|
from django.db.utils import OperationalError
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ class Command(CollectStatic):
|
|||||||
js_filename = 'webclient-{}.js'
|
js_filename = 'webclient-{}.js'
|
||||||
|
|
||||||
def handle(self, **options: Any) -> str:
|
def handle(self, **options: Any) -> str:
|
||||||
|
if options['link']:
|
||||||
|
raise CommandError("Option 'link' is not supported.")
|
||||||
try:
|
try:
|
||||||
self.view = WebclientJavaScriptView()
|
self.view = WebclientJavaScriptView()
|
||||||
except OperationalError:
|
except OperationalError:
|
||||||
@ -26,24 +29,37 @@ class Command(CollectStatic):
|
|||||||
return super().handle(**options)
|
return super().handle(**options)
|
||||||
|
|
||||||
def collect(self) -> Dict[str, Any]:
|
def collect(self) -> Dict[str, Any]:
|
||||||
|
result = super().collect()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
destination_dir = os.path.join(settings.STATICFILES_DIRS[0], 'js')
|
destination_dir = os.path.join(settings.STATIC_ROOT, 'js')
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# If the user does not want do have staticfiles, he should not get
|
# If the user does not want do have staticfiles, he should not get
|
||||||
# the webclient files either.
|
# the webclient files either.
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
if self.dry_run:
|
||||||
|
self.log('Pretending to write WebclientJavaScriptView for all realms.', level=1)
|
||||||
else:
|
else:
|
||||||
if not os.path.exists(destination_dir):
|
if not os.path.exists(destination_dir):
|
||||||
os.makedirs(destination_dir)
|
os.makedirs(destination_dir)
|
||||||
|
|
||||||
for realm in self.realms:
|
for realm in self.realms:
|
||||||
filename = self.js_filename.format(realm)
|
filename = self.js_filename.format(realm)
|
||||||
content = self.view.get(realm=realm).content
|
# Matches only the basename.
|
||||||
|
if matches_patterns(filename, self.ignore_patterns):
|
||||||
|
continue
|
||||||
path = os.path.join(destination_dir, filename)
|
path = os.path.join(destination_dir, filename)
|
||||||
|
if matches_patterns(path, self.ignore_patterns):
|
||||||
|
continue
|
||||||
|
|
||||||
|
content = self.view.get(realm=realm).content
|
||||||
with open(path, 'wb+') as f:
|
with open(path, 'wb+') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
self.stdout.write("Written WebclientJavaScriptView for realm {} to '{}'".format(
|
message = "Written WebclientJavaScriptView for realm {} to '{}'".format(
|
||||||
realm,
|
realm,
|
||||||
path))
|
path)
|
||||||
|
self.log(message, level=1)
|
||||||
|
result['modified'].append(path)
|
||||||
|
|
||||||
return super().collect()
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user