From f4b1acb7575c41d9bf7589288731ea92a31580be Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 14 Jan 2025 18:18:13 +0100 Subject: [PATCH] changed paths to have vue3 as standard --- cookbook/templates/frontend/tandoor.html | 13 +++++++++++++ cookbook/urls.py | 23 +++++++---------------- cookbook/views/views.py | 21 +++++++++++---------- recipes/settings.py | 6 ++---- recipes/urls.py | 6 +++++- vue3/src/apps/tandoor/main.ts | 3 +-- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/cookbook/templates/frontend/tandoor.html b/cookbook/templates/frontend/tandoor.html index cdaba2d9a..ee4b90958 100644 --- a/cookbook/templates/frontend/tandoor.html +++ b/cookbook/templates/frontend/tandoor.html @@ -17,6 +17,8 @@ + + @@ -40,6 +42,17 @@ diff --git a/cookbook/urls.py b/cookbook/urls.py index af114c479..a86ca4b7f 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -75,9 +75,7 @@ for p in PLUGINS: pass urlpatterns = [ - path('', views.index, name='index'), - re_path(r'^v3/.*', views.vue3, name='vue3'), - #path('v3/', views.vue3, name='vue3'), + path('setup/', views.setup, name='view_setup'), path('no-group', views.no_groups, name='view_no_group'), path('space-overview', views.space_overview, name='view_space_overview'), @@ -86,26 +84,15 @@ urlpatterns = [ path('no-perm', views.no_perm, name='view_no_perm'), path('invite/', views.invite_link, name='view_invite'), path('system/', views.system, name='view_system'), - path('search/', views.search, name='view_search'), - path('books/', views.books, name='view_books'), - path('plan/', views.meal_plan, name='view_plan'), - path('shopping/', lists.shopping_list, name='view_shopping'), - path('settings/', views.user_settings, name='view_settings'), + path('settings-shopping/', views.shopping_settings, name='view_shopping_settings'), # TODO rename to search settings - path('history/', views.history, name='view_history'), - path('ingredient-editor/', views.ingredient_editor, name='view_ingredient_editor'), - path('property-editor/', views.property_editor, name='view_property_editor'), + path('abuse/', views.report_share_abuse, name='view_report_share_abuse'), path('api/import/', api.import_files, name='view_import'), path('import-response//', import_export.import_response, name='view_import_response'), path('export/', import_export.export_recipe, name='view_export'), path('export-response//', import_export.export_response, name='view_export_response'), path('export-file//', import_export.export_file, name='view_export_file'), - path('view/recipe/', views.recipe_view, name='view_recipe'), - path('view/recipe//', views.recipe_view, name='view_recipe'), - path('new/recipe-import//', new.create_new_external_recipe, name='new_recipe_import'), - path('new/share-link//', new.share_link, name='new_share_link'), - path('edit/recipe//', edit.switch_recipe, name='edit_recipe'), # for internal use only path('edit/recipe/internal//', edit.internal_recipe_update, name='edit_internal_recipe'), @@ -145,6 +132,10 @@ urlpatterns = [ path('offline/', views.offline, name='view_offline'), path('service-worker.js', (TemplateView.as_view(template_name="sw.js", content_type='application/javascript')), name='service_worker'), path('manifest.json', views.web_manifest, name='web_manifest'), + + + path('', views.index, name='index'), + path('', views.index, name='index'), ] generic_models = (Recipe, RecipeImport, Storage, ConnectorConfig, RecipeBook, SyncLog, Sync, Comment, RecipeBookEntry, InviteLink, UserSpace, Space) diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 5f820c6da..758e76f72 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -39,7 +39,13 @@ def index(request): if User.objects.count() < 1 and 'django.contrib.auth.backends.RemoteUserBackend' not in settings.AUTHENTICATION_BACKENDS: return HttpResponseRedirect(reverse_lazy('view_setup')) - return HttpResponseRedirect(reverse('vue3')) + if has_group_permission(request.user, ('guest', )): + return render(request, 'frontend/tandoor.html', {}) + else: + if request.user.is_authenticated: + return HttpResponseRedirect(reverse('view_no_group')) + else: + return HttpResponseRedirect(reverse('account_login') + '?next=' + request.path) def search(request): @@ -523,20 +529,15 @@ def web_manifest(request): "name": _("Plan"), "short_name": _("Plan"), "description": _("View your meal Plan"), - "url": "./plan" - }, { - "name": _("Books"), - "short_name": _("Books"), - "description": _("View your cookbooks"), - "url": "./books" + "url": "./mealplan" }, { "name": _("Shopping"), "short_name": _("Shopping"), "description": _("View your shopping lists"), - "url": "./shopping/" + "url": "./shopping" }], "share_target": { - "action": "/data/import/url", + "action": "/recipe/import", "method": "GET", "params": { "title": "title", @@ -590,7 +591,7 @@ def test2(request): @group_required('guest') -def vue3(request): +def tandoor_frontend(request): return render(request, 'frontend/tandoor.html', {}) diff --git a/recipes/settings.py b/recipes/settings.py index bfebd0a2e..068613d46 100644 --- a/recipes/settings.py +++ b/recipes/settings.py @@ -48,10 +48,8 @@ STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") # Get vars from .env files SECRET_KEY = os.getenv('SECRET_KEY', 'INSECURE_STANDARD_KEY_SET_IN_ENV') -DEBUG = extract_bool('DEBUG', True) -DEBUG_TOOLBAR = extract_bool('DEBUG_TOOLBAR', True) - -V3_BETA = extract_bool('V3_BETA', False) +DEBUG = extract_bool('DEBUG', False) +DEBUG_TOOLBAR = extract_bool('DEBUG_TOOLBAR', False) LOG_LEVEL = os.getenv("LOG_LEVEL", "WARNING") diff --git a/recipes/urls.py b/recipes/urls.py index 9d251c10f..f71a39e2a 100644 --- a/recipes/urls.py +++ b/recipes/urls.py @@ -24,7 +24,6 @@ from django.views.static import serve from django_js_reverse import views as reverse_views urlpatterns = [ - path('', include('cookbook.urls')), path('admin/', admin.site.urls), path('accounts/', include('allauth.urls')), path('i18n/', include('django.conf.urls.i18n')), @@ -56,3 +55,8 @@ for p in settings.PLUGINS: if settings.DEBUG: print(f'ERROR failed loading urls for plugin <{p["name"]}>') traceback.format_exc() + +# include cookbook urls last because it has a catchall view to the tandoor frontend +urlpatterns.append( + path('', include('cookbook.urls')), +) diff --git a/vue3/src/apps/tandoor/main.ts b/vue3/src/apps/tandoor/main.ts index 071225a88..f05fab6b2 100644 --- a/vue3/src/apps/tandoor/main.ts +++ b/vue3/src/apps/tandoor/main.ts @@ -61,8 +61,7 @@ const routes = [ ] const router = createRouter({ - // TODO configure proper history mode - history: createWebHistory('v3/'), + history: createWebHistory(), routes, })