From d31b2dd348b82a487819882de9de8ac793e5187d Mon Sep 17 00:00:00 2001 From: Artus Date: Sun, 28 Apr 2019 15:41:00 +0200 Subject: [PATCH] loads of work... --- .gitignore | 1 + cookAssistant/urls.py | 95 ++++++------- frontend/src/App.vue | 22 +-- frontend/src/api.js | 1 + frontend/src/components/CategoryTabs.vue | 33 ----- frontend/src/components/RessourceField.vue | 1 - frontend/src/components/planning/Day.vue | 27 ++++ frontend/src/components/planning/Meal.vue | 19 +++ frontend/src/components/planning/Options.vue | 65 +++++++++ frontend/src/components/planning/Week.vue | 65 +++++++++ .../src/components/recipes/Ingredient.vue | 5 + .../src/components/recipes/IngredientList.vue | 51 ++++--- .../src/components/recipes/RecipeDetails.vue | 104 ++++++-------- .../src/components/recipes/RecipeList.vue | 58 +++++--- frontend/src/router.js | 10 +- frontend/src/routes/Planning.vue | 129 ++++++------------ frontend/src/routes/Recipes.vue | 25 ++-- frontend/webpack-stats.json | 2 +- planning/models.py | 32 +++-- planning/serializers.py | 8 ++ planning/views.py | 12 +- 21 files changed, 447 insertions(+), 318 deletions(-) delete mode 100644 frontend/src/components/CategoryTabs.vue create mode 100644 frontend/src/components/planning/Day.vue create mode 100644 frontend/src/components/planning/Meal.vue create mode 100644 frontend/src/components/planning/Options.vue create mode 100644 frontend/src/components/planning/Week.vue create mode 100644 planning/serializers.py diff --git a/.gitignore b/.gitignore index 70b6bfe..4c9e788 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ db.sqlite3 run_dev.sh +**/migrations/ diff --git a/cookAssistant/urls.py b/cookAssistant/urls.py index 3269c04..8711c8c 100644 --- a/cookAssistant/urls.py +++ b/cookAssistant/urls.py @@ -1,46 +1,49 @@ -"""cookAssistant URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path, include -from django.views.generic import TemplateView - -from recipe_book import views -from rest_framework_nested import routers - -router = routers.DefaultRouter() -router.register(r'recips', views.RecipesViewSet) -router.register(r'ingdts', views.IngredientViewSet) - -amounts_router = routers.NestedDefaultRouter( - router, r'recips', lookup="recipe" -) -amounts_router.register( - r'amounts', views.IngredientWAmountViewSet, - base_name="recipe-ingdt-amounts" -) - - -urlpatterns = [ - path('admin/', admin.site.urls), - path('api/', include(router.urls)), - path('api/', include(amounts_router.urls)), - path('', - TemplateView.as_view( - template_name="application.html" - ), - name="app" - ), -] +"""cookAssistant URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include +from django.views.generic import TemplateView + +from recipe_book import views +from planning import views as planning_views +from rest_framework_nested import routers + +router = routers.DefaultRouter() +router.register(r'recips', views.RecipesViewSet) +router.register(r'ingdts', views.IngredientViewSet) + +amounts_router = routers.NestedDefaultRouter( + router, r'recips', lookup="recipe" +) +amounts_router.register( + r'amounts', views.IngredientWAmountViewSet, + base_name="recipe-ingdt-amounts" +) + +router.register(r'planning', planning_views.MealViewSet) + + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api/', include(router.urls)), + path('api/', include(amounts_router.urls)), + path('', + TemplateView.as_view( + template_name="application.html" + ), + name="app" + ), +] diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 5a9cfb6..6cd0bbf 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,14 +1,7 @@ @@ -58,12 +49,6 @@ import NotFound from './routes/NotFound' -export const RecipeCategories = { - 0: "Petit-déjeuner", - 1: "Entrée", - 2: "Plat", - 3: "Dessert" -} // *** TOOLS *** // // * create_recipe: go to creation page @@ -83,7 +68,6 @@ export default { data () { return { links: [], - categories: RecipeCategories, showNav: null,// } }, diff --git a/frontend/src/api.js b/frontend/src/api.js index b4357cb..786d3c9 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -151,4 +151,5 @@ export default { ingredients: mountNestedEndPoint( `${baseUrl}/recips/*/amounts/` ), + meals: mountEndPoint(`${baseUrl}/planning/`), } diff --git a/frontend/src/components/CategoryTabs.vue b/frontend/src/components/CategoryTabs.vue deleted file mode 100644 index 2756039..0000000 --- a/frontend/src/components/CategoryTabs.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - diff --git a/frontend/src/components/RessourceField.vue b/frontend/src/components/RessourceField.vue index d588c66..e1905b3 100644 --- a/frontend/src/components/RessourceField.vue +++ b/frontend/src/components/RessourceField.vue @@ -1,7 +1,6 @@ + + + diff --git a/frontend/src/components/planning/Meal.vue b/frontend/src/components/planning/Meal.vue new file mode 100644 index 0000000..d7a51d4 --- /dev/null +++ b/frontend/src/components/planning/Meal.vue @@ -0,0 +1,19 @@ + + + diff --git a/frontend/src/components/planning/Options.vue b/frontend/src/components/planning/Options.vue new file mode 100644 index 0000000..037d3bb --- /dev/null +++ b/frontend/src/components/planning/Options.vue @@ -0,0 +1,65 @@ + + + diff --git a/frontend/src/components/planning/Week.vue b/frontend/src/components/planning/Week.vue new file mode 100644 index 0000000..e6bf848 --- /dev/null +++ b/frontend/src/components/planning/Week.vue @@ -0,0 +1,65 @@ + + + diff --git a/frontend/src/components/recipes/Ingredient.vue b/frontend/src/components/recipes/Ingredient.vue index 8d22405..7d176c5 100644 --- a/frontend/src/components/recipes/Ingredient.vue +++ b/frontend/src/components/recipes/Ingredient.vue @@ -72,6 +72,11 @@ }, markUpdated () { this.updated = true + }, + resetFields () { + this.item.ingredient = {} + this.item.amount = null + this.item.unit = null } }, watch: { diff --git a/frontend/src/components/recipes/IngredientList.vue b/frontend/src/components/recipes/IngredientList.vue index bdb7276..2a3f9db 100644 --- a/frontend/src/components/recipes/IngredientList.vue +++ b/frontend/src/components/recipes/IngredientList.vue @@ -1,26 +1,36 @@ diff --git a/frontend/src/router.js b/frontend/src/router.js index d874ef1..4edb689 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -8,7 +8,6 @@ import Planning from './routes/Planning' import RecipeDetails from './components/recipes/RecipeDetails' import RecipeList from './components/recipes/RecipeList' -import CategoryTabs from './components/CategoryTabs' Vue.use(Router) @@ -20,17 +19,16 @@ const router = new Router({ }, { path: '/recipes', - components: { default: Recipes, - extension: CategoryTabs, }, + component: Recipes, meta: { title: "Recettes", icon:"book" }, children: [ + { path: '', + component: RecipeList, + meta: {}}, { path: 'id/:id', component: RecipeDetails, meta: { subtitle: "Détails", } }, - { path: 'category/:cat', - component: RecipeList, - meta: { subtitle: "Liste", } }, { path: '*', component: NotFound } ] diff --git a/frontend/src/routes/Planning.vue b/frontend/src/routes/Planning.vue index fb34624..ce51f71 100644 --- a/frontend/src/routes/Planning.vue +++ b/frontend/src/routes/Planning.vue @@ -1,91 +1,38 @@ - - - - - + + + + + diff --git a/frontend/src/routes/Recipes.vue b/frontend/src/routes/Recipes.vue index c86da53..90c6e43 100644 --- a/frontend/src/routes/Recipes.vue +++ b/frontend/src/routes/Recipes.vue @@ -1,14 +1,13 @@ - - - - - diff --git a/frontend/webpack-stats.json b/frontend/webpack-stats.json index 12990bd..fe7d5f7 100644 --- a/frontend/webpack-stats.json +++ b/frontend/webpack-stats.json @@ -1 +1 @@ -{"status":"done","publicPath":"http://localhost:8080/","chunks":{"null":[{"name":"0.js","publicPath":"http://localhost:8080/0.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/0.js"}],"app":[{"name":"app.js","publicPath":"http://localhost:8080/app.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/app.js"},{"name":"app.bb93e89c95f5e29b766f.hot-update.js","publicPath":"http://localhost:8080/app.bb93e89c95f5e29b766f.hot-update.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/app.bb93e89c95f5e29b766f.hot-update.js"}]}} \ No newline at end of file +{"status":"done","publicPath":"http://localhost:8080/","error":"ModuleError","message":"Module Error (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):\n(Emitted value instead of an instance of Error) \n\n Errors compiling template:\n\n tag has no matching end tag.\n\n 12 | >\n 13 |