diff --git a/cookbook/migrations/0064_auto_20200625_2329.py b/cookbook/migrations/0064_auto_20200625_2329.py new file mode 100644 index 000000000..cd19b6a51 --- /dev/null +++ b/cookbook/migrations/0064_auto_20200625_2329.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.7 on 2020-06-25 21:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0063_auto_20200625_2230'), + ] + + operations = [ + migrations.AlterField( + model_name='recipe', + name='file_path', + field=models.CharField(blank=True, default='', max_length=512), + ), + migrations.AlterField( + model_name='recipe', + name='file_uid', + field=models.CharField(blank=True, default='', max_length=256), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 23f3f1250..fe2d5d2da 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -167,8 +167,8 @@ class Recipe(models.Model): name = models.CharField(max_length=128) image = models.ImageField(upload_to='recipes/', blank=True, null=True) storage = models.ForeignKey(Storage, on_delete=models.PROTECT, blank=True, null=True) - file_uid = models.CharField(max_length=256, default="") - file_path = models.CharField(max_length=512, default="") + file_uid = models.CharField(max_length=256, default="", blank=True) + file_path = models.CharField(max_length=512, default="", blank=True) link = models.CharField(max_length=512, null=True, blank=True) cors_link = models.CharField(max_length=1024, null=True, blank=True) keywords = models.ManyToManyField(Keyword, blank=True) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 70260fdeb..d166c3cb8 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -1,5 +1,7 @@ from django.contrib.auth.models import User from rest_framework import serializers +from rest_framework.exceptions import APIException +from rest_framework.fields import CurrentUserDefault from cookbook.models import MealPlan, MealType, Recipe, ViewLog, UserPreference, Storage, Sync, SyncLog, Keyword, Unit, Ingredient, Comment, RecipeImport, RecipeBook, RecipeBookEntry, ShareLink, CookLog, Food, Step from cookbook.templatetags.custom_tags import markdown diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html index abaa50c7a..82c1ecb99 100644 --- a/cookbook/templates/forms/edit_internal_recipe.html +++ b/cookbook/templates/forms/edit_internal_recipe.html @@ -61,6 +61,7 @@ + @@ -93,7 +94,7 @@ }, methods: { loadRecipe: function () { - this.$http.get("{% url 'api:recipe-list' %}{{ recipe.pk }}").then((response) => { + this.$http.get("{% url 'api:recipe-detail' recipe.pk %}").then((response) => { this.recipe = response.data; this.loading = false }).catch((err) => { @@ -102,6 +103,13 @@ console.log(err) }) }, + updateRecipe: function () { + this.$http.put("{% url 'api:recipe-detail' recipe.pk %}", this.recipe).then((response) => { + console.log(response) + }).catch((err) => { + console.log(err) + }) + }, searchKeywords: function (query) { this.keywords_loading = true this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query).then((response) => {