basic api
This commit is contained in:
parent
a3dc5f283a
commit
2fcd207dc7
9
cookbook/serializer.py
Normal file
9
cookbook/serializer.py
Normal file
@ -0,0 +1,9 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from cookbook.models import MealPlan
|
||||
|
||||
|
||||
class MealPlanSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = MealPlan
|
||||
fields = ['recipe', 'title', 'note', 'meal_type']
|
6
cookbook/static/js/vue.min.js
vendored
Normal file
6
cookbook/static/js/vue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -7,6 +7,7 @@
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{% static 'custom/css/markdown_blockquote.css' %}">
|
||||
<script type="application/javascript" src="{% static 'js/vue.min.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,11 +1,15 @@
|
||||
from pydoc import locate
|
||||
|
||||
from django.urls import path
|
||||
from django.urls import path, include
|
||||
from rest_framework import routers
|
||||
|
||||
from .views import *
|
||||
from cookbook.views import api, import_export
|
||||
from cookbook.helper import dal
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'meal-plan', api.MealPlanViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
path('setup/', views.setup, name='view_setup'),
|
||||
@ -50,6 +54,9 @@ urlpatterns = [
|
||||
path('dal/unit/', dal.UnitAutocomplete.as_view(), name='dal_unit'),
|
||||
|
||||
path('docs/markdown/', views.markdown_info, name='docs_markdown'),
|
||||
|
||||
path('api/', include((router.urls, 'api'))),
|
||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
|
||||
generic_models = (Recipe, RecipeImport, Storage, RecipeBook, MealPlan, SyncLog, Sync, Comment, RecipeBookEntry, Keyword, Ingredient)
|
||||
|
@ -6,11 +6,19 @@ from django.contrib import messages
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.translation import gettext as _
|
||||
from rest_framework import viewsets, permissions
|
||||
|
||||
from cookbook.helper.permission_helper import group_required
|
||||
from cookbook.models import Recipe, Sync, Storage, CookLog
|
||||
from cookbook.models import Recipe, Sync, Storage, CookLog, MealPlan
|
||||
from cookbook.provider.dropbox import Dropbox
|
||||
from cookbook.provider.nextcloud import Nextcloud
|
||||
from cookbook.serializer import MealPlanSerializer
|
||||
|
||||
|
||||
class MealPlanViewSet(viewsets.ModelViewSet):
|
||||
queryset = MealPlan.objects.all()
|
||||
serializer_class = MealPlanSerializer
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
|
||||
def get_recipe_provider(recipe):
|
||||
|
Loading…
Reference in New Issue
Block a user