From 24ed6a1cd2e012e3238b88cf85a448d332c6b5c9 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 12 Jan 2021 20:51:28 +0100 Subject: [PATCH] recipe stuff --- boot.sh | 1 + cookbook/templates/javascript_urls.html | 18 +++++++ cookbook/templates/test.html | 7 +++ recipes/settings.py | 5 ++ recipes/urls.py | 2 + requirements.txt | 1 + vue/src/apps/RecipeView/RecipeView.vue | 27 ++++------ vue/src/components/RecipeContextMenu.vue | 64 ++++++++++++++++++++++++ vue/src/utils/api.js | 12 +++++ vue/src/utils/django.js | 12 ----- vue/src/utils/utils.js | 55 +++++++++++++++++++- vue/webpack-stats.json | 2 +- 12 files changed, 175 insertions(+), 31 deletions(-) create mode 100644 cookbook/templates/javascript_urls.html create mode 100644 vue/src/components/RecipeContextMenu.vue delete mode 100644 vue/src/utils/django.js diff --git a/boot.sh b/boot.sh index d76fa75a..0d1d47d9 100644 --- a/boot.sh +++ b/boot.sh @@ -4,6 +4,7 @@ source venv/bin/activate echo "Updating database" python manage.py migrate python manage.py collectstatic --noinput +python manage.py collectstatic_js_reverse echo "Done" chmod -R 755 /opt/recipes/mediafiles diff --git a/cookbook/templates/javascript_urls.html b/cookbook/templates/javascript_urls.html new file mode 100644 index 00000000..5eb1ca0a --- /dev/null +++ b/cookbook/templates/javascript_urls.html @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/cookbook/templates/test.html b/cookbook/templates/test.html index 79ceb0a6..8bf6d6e6 100644 --- a/cookbook/templates/test.html +++ b/cookbook/templates/test.html @@ -16,8 +16,15 @@ {% block script %} + {% if debug %} + + {% else %} + + {% endif %} + {% render_bundle 'chunk-vendors' %} diff --git a/recipes/settings.py b/recipes/settings.py index 4893cda5..1146fb2f 100644 --- a/recipes/settings.py +++ b/recipes/settings.py @@ -24,6 +24,10 @@ SECRET_KEY = os.getenv('SECRET_KEY') if os.getenv('SECRET_KEY') else 'INSECURE_S DEBUG = bool(int(os.getenv('DEBUG', True))) +INTERNAL_IPS = [ + '127.0.0.1', +] + # allow djangos wsgi server to server mediafiles GUNICORN_MEDIA = bool(int(os.getenv('GUNICORN_MEDIA', True))) @@ -74,6 +78,7 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', 'django_cleanup.apps.CleanupConfig', 'webpack_loader', + 'django_js_reverse', 'cookbook.apps.CookbookConfig', ] diff --git a/recipes/urls.py b/recipes/urls.py index d975d22c..26b54a96 100644 --- a/recipes/urls.py +++ b/recipes/urls.py @@ -20,6 +20,7 @@ from django.contrib import admin from django.urls import include, path from django.views.i18n import JavaScriptCatalog from django.views.static import serve +from django_js_reverse import views as reverse_views urlpatterns = [ path('', include('cookbook.urls')), @@ -31,6 +32,7 @@ urlpatterns = [ JavaScriptCatalog.as_view(domain='django'), name='javascript-catalog' ), + url(r'^jsreverse.json$', reverse_views.urls_js, name='js_reverse'), ] if settings.GUNICORN_MEDIA or settings.DEBUG: diff --git a/requirements.txt b/requirements.txt index ef3ba1dc..35fb9e72 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,3 +29,4 @@ microdata==0.7.1 django-random-queryset==0.1.3 Jinja2==2.11.2 django-webpack-loader==0.7.0 +django-js-reverse==0.9.1 \ No newline at end of file diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index cc991696..c7498866 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -1,6 +1,7 @@