mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
Remove javascript rendering (#8713)
This commit is contained in:
parent
88bfb23362
commit
6634bc54bd
@ -1,71 +0,0 @@
|
|||||||
"""Pull rendered copies of the templated.
|
|
||||||
|
|
||||||
Only used for testing the js files! - This file is omitted from coverage.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os # pragma: no cover
|
|
||||||
import pathlib # pragma: no cover
|
|
||||||
|
|
||||||
from InvenTree.unit_test import InvenTreeTestCase # pragma: no cover
|
|
||||||
|
|
||||||
|
|
||||||
class RenderJavascriptFiles(InvenTreeTestCase): # pragma: no cover
|
|
||||||
"""A unit test to "render" javascript files.
|
|
||||||
|
|
||||||
The server renders templated javascript files,
|
|
||||||
we need the fully-rendered files for linting and static tests.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def download_file(self, filename, prefix):
|
|
||||||
"""Function to `download`(copy) a file to a temporary firectory."""
|
|
||||||
url = os.path.join(prefix, filename)
|
|
||||||
|
|
||||||
response = self.client.get(url)
|
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
|
|
||||||
output_dir = os.path.join(here, '..', '..', 'js_tmp')
|
|
||||||
|
|
||||||
output_dir = os.path.abspath(output_dir)
|
|
||||||
|
|
||||||
if not os.path.exists(output_dir):
|
|
||||||
os.mkdir(output_dir)
|
|
||||||
|
|
||||||
output_file = os.path.join(output_dir, filename)
|
|
||||||
|
|
||||||
with open(output_file, 'wb') as output:
|
|
||||||
output.write(response.content)
|
|
||||||
|
|
||||||
def download_files(self, subdir, prefix):
|
|
||||||
"""Download files in directory."""
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
|
|
||||||
js_template_dir = os.path.join(here, '..', 'templates', 'js')
|
|
||||||
|
|
||||||
directory = os.path.join(js_template_dir, subdir)
|
|
||||||
|
|
||||||
directory = os.path.abspath(directory)
|
|
||||||
|
|
||||||
js_files = pathlib.Path(directory).rglob('*.js')
|
|
||||||
|
|
||||||
n = 0
|
|
||||||
|
|
||||||
for f in js_files:
|
|
||||||
js = os.path.basename(f)
|
|
||||||
|
|
||||||
self.download_file(js, prefix)
|
|
||||||
|
|
||||||
n += 1
|
|
||||||
|
|
||||||
return n
|
|
||||||
|
|
||||||
def test_render_files(self):
|
|
||||||
"""Look for all javascript files."""
|
|
||||||
n = 0
|
|
||||||
|
|
||||||
print('Rendering javascript files...')
|
|
||||||
|
|
||||||
n += self.download_files('translated', '/js/i18n')
|
|
||||||
n += self.download_files('dynamic', '/js/dynamic')
|
|
||||||
|
|
||||||
print(f'Rendered {n} javascript files.')
|
|
@ -44,13 +44,7 @@ urls = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Do not redirect requests to any of these paths
|
# Do not redirect requests to any of these paths
|
||||||
paths_ignore = [
|
paths_ignore = ['/api/', '/auth/', settings.MEDIA_URL, settings.STATIC_URL]
|
||||||
'/api/',
|
|
||||||
'/auth/',
|
|
||||||
'/js/', # TODO - remove when CUI is removed
|
|
||||||
settings.MEDIA_URL,
|
|
||||||
settings.STATIC_URL,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class AuthRequiredMiddleware:
|
class AuthRequiredMiddleware:
|
||||||
|
8
tasks.py
8
tasks.py
@ -917,13 +917,6 @@ def worker(c):
|
|||||||
manage(c, 'qcluster', pty=True)
|
manage(c, 'qcluster', pty=True)
|
||||||
|
|
||||||
|
|
||||||
# Testing tasks
|
|
||||||
@task
|
|
||||||
def render_js_files(c):
|
|
||||||
"""Render templated javascript files (used for static testing)."""
|
|
||||||
manage(c, 'test InvenTree.ci_render_js')
|
|
||||||
|
|
||||||
|
|
||||||
@task(post=[translate_stats, static, server])
|
@task(post=[translate_stats, static, server])
|
||||||
def test_translations(c):
|
def test_translations(c):
|
||||||
"""Add a fictional language to test if each component is ready for translations."""
|
"""Add a fictional language to test if each component is ready for translations."""
|
||||||
@ -1531,7 +1524,6 @@ internal = Collection(
|
|||||||
frontend_compile,
|
frontend_compile,
|
||||||
frontend_install,
|
frontend_install,
|
||||||
frontend_trans,
|
frontend_trans,
|
||||||
render_js_files,
|
|
||||||
rebuild_models,
|
rebuild_models,
|
||||||
rebuild_thumbnails,
|
rebuild_thumbnails,
|
||||||
showmigrations,
|
showmigrations,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user