partially working steps edit view
This commit is contained in:
23
cookbook/migrations/0064_auto_20200625_2329.py
Normal file
23
cookbook/migrations/0064_auto_20200625_2329.py
Normal file
@ -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),
|
||||||
|
),
|
||||||
|
]
|
@ -167,8 +167,8 @@ class Recipe(models.Model):
|
|||||||
name = models.CharField(max_length=128)
|
name = models.CharField(max_length=128)
|
||||||
image = models.ImageField(upload_to='recipes/', blank=True, null=True)
|
image = models.ImageField(upload_to='recipes/', blank=True, null=True)
|
||||||
storage = models.ForeignKey(Storage, on_delete=models.PROTECT, 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_uid = models.CharField(max_length=256, default="", blank=True)
|
||||||
file_path = models.CharField(max_length=512, default="")
|
file_path = models.CharField(max_length=512, default="", blank=True)
|
||||||
link = models.CharField(max_length=512, null=True, blank=True)
|
link = models.CharField(max_length=512, null=True, blank=True)
|
||||||
cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
||||||
keywords = models.ManyToManyField(Keyword, blank=True)
|
keywords = models.ManyToManyField(Keyword, blank=True)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from rest_framework import serializers
|
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.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
|
from cookbook.templatetags.custom_tags import markdown
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button type="button" @click="updateRecipe()">Save</button>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -93,7 +94,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadRecipe: function () {
|
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.recipe = response.data;
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@ -102,6 +103,13 @@
|
|||||||
console.log(err)
|
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) {
|
searchKeywords: function (query) {
|
||||||
this.keywords_loading = true
|
this.keywords_loading = true
|
||||||
this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query).then((response) => {
|
this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query).then((response) => {
|
||||||
|
Reference in New Issue
Block a user