diff --git a/frontend/src/components/daily_recipe_detail.vue b/frontend/src/components/daily_recipe_detail.vue new file mode 100644 index 0000000..efd2311 --- /dev/null +++ b/frontend/src/components/daily_recipe_detail.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/frontend/src/components/week_recipe.vue b/frontend/src/components/week_recipe.vue index a07e28d..8802566 100644 --- a/frontend/src/components/week_recipe.vue +++ b/frontend/src/components/week_recipe.vue @@ -6,40 +6,48 @@ prop="date" label="日期" :formatter="formatDate" + width="50px" > + + + @@ -56,13 +64,15 @@ @@ -108,12 +121,23 @@ export default { margin: 20px 0; width: 100%; } -ul#meal { - list-style-type: none; - padding: 0; - margin: 0; + +.el-tag#meal a:link { + text-decoration: none; } -ul#meal li { - margin: 0 10px; +.el-tag#meal a:visited { + text-decoration: none; +} +.el-tag#meal a:hover { + text-decoration: underline; +} +.el-tag#meal a:active { + text-decoration: underline; +} +.el-tag { + margin: 0px 5px 0 0px; +} +.el-tag + .el-tag { + margin: 5px 0px 0 0px; } diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 0368594..2e4e859 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router' import Home from '@/views/home.vue' import RecipeDetail from '@/views/recipeDetail.vue' import WeekRecipe from '@/views/weekRecipe.vue' +import DailyRecipeDetail from '@/views/dailyRecipeDetail.vue' const routes = [ { @@ -19,6 +20,11 @@ const routes = [ name: "WeekRecipe", component: WeekRecipe }, + { + path: '/daily-recipe/:id', + name: "DailyRecipeDetail", + component: DailyRecipeDetail + }, ]; const router = createRouter({ diff --git a/frontend/src/views/dailyRecipeDetail.vue b/frontend/src/views/dailyRecipeDetail.vue new file mode 100644 index 0000000..c51277c --- /dev/null +++ b/frontend/src/views/dailyRecipeDetail.vue @@ -0,0 +1,33 @@ + + + diff --git a/recipe/models.py b/recipe/models.py index cbc3021..eca4b6d 100644 --- a/recipe/models.py +++ b/recipe/models.py @@ -99,4 +99,5 @@ class DailyRecipe(models.Model): date = date.replace(year=self.date.year, month=self.date.month, day=self.date.day, hour=0, minute=0) data['date'] = utils.timestamp_of(utils.day_start(date)) + data['id'] = self.id return data diff --git a/recipe/serializers.py b/recipe/serializers.py index 2f7b379..eedc7dc 100644 --- a/recipe/serializers.py +++ b/recipe/serializers.py @@ -1,17 +1,26 @@ +from os import read from django.contrib.auth.models import User, Group from rest_framework import serializers import recipe.models -class RecipeSerializer(serializers.HyperlinkedModelSerializer): +class RecipeSerializer(serializers.ModelSerializer): id = serializers.IntegerField(read_only=True) class Meta: model = recipe.models.Recipe fields = '__all__' -class WeekRecipeSerializer(serializers.HyperlinkedModelSerializer): +class WeekRecipeSerializer(serializers.ModelSerializer): class Meta: model = recipe.models.DailyRecipe fields = '__all__' + + +class DailyRecipeSerializer(serializers.ModelSerializer): + id = serializers.IntegerField(read_only=True) + recipes = RecipeSerializer(many=True) + class Meta: + model = recipe.models.DailyRecipe + fields = '__all__' diff --git a/recipe/urls.py b/recipe/urls.py index 0f7aa50..20ceeb2 100644 --- a/recipe/urls.py +++ b/recipe/urls.py @@ -11,4 +11,6 @@ urlpatterns = [ url(r'^recipe/(?P\d+)$', views.RecipeAPI.as_view(), name='recipe-detail'), url(r'^recipe/$', views.RecipeListAPI.as_view()), url(r'^week-recipe/$', views.WeekRecipeListAPI.as_view()), + url(r'^daily-recipe/(?P\d+)$', views.DailyRecipeAPI.as_view(), + name='dailyrecipe-detail'), ] diff --git a/recipe/views.py b/recipe/views.py index 8735aaa..0595d45 100644 --- a/recipe/views.py +++ b/recipe/views.py @@ -32,10 +32,11 @@ class RecipeListAPI(rest_framework.generics.ListAPIView, class WeekRecipeListAPI(rest_framework.generics.ListAPIView, - rest_framework.generics.CreateAPIView): + rest_framework.generics.CreateAPIView): queryset = recipe.models.DailyRecipe.objects.all() serializer_class = recipe.serializers.WeekRecipeSerializer + def post(self, request, *args, **kwargs): # Monday == 0 ... Sunday == 6 today = localtime() @@ -62,3 +63,9 @@ class WeekRecipeListAPI(rest_framework.generics.ListAPIView, data.append(daily_recipe.serialize()) return Response(data) + + +class DailyRecipeAPI(rest_framework.generics.RetrieveUpdateAPIView): + + queryset = recipe.models.DailyRecipe.objects.all() + serializer_class = recipe.serializers.DailyRecipeSerializer