trying to fix things
This commit is contained in:
parent
27d6482082
commit
a6e351736b
@ -51,7 +51,7 @@ class Chowdown(Integration):
|
||||
recipe = Recipe.objects.create(name=title, created_by=self.request.user, internal=True, space=self.request.space)
|
||||
|
||||
for k in tags.split(','):
|
||||
keyword, created = Keyword.objects.get_or_create(name=k.strip(), space=self.request.space)
|
||||
keyword, created = Keyword.get_or_create(name=k.strip(), space=self.request.space)
|
||||
recipe.keywords.add(keyword)
|
||||
|
||||
step = Step.objects.create(
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.4 on 2021-07-03 08:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0144_alter_userpreference_search_style'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='userpreference',
|
||||
name='use_fractions',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
@ -299,9 +299,10 @@ class Keyword(ExportModelOperationsMixin('keyword'), MP_Node, PermissionModelMix
|
||||
kwargs['name'] = kwargs['name'].strip()
|
||||
q = self.get_tree().filter(name=kwargs['name'], space=kwargs['space'])
|
||||
if len(q) != 0:
|
||||
return q[0]
|
||||
return q[0], False
|
||||
else:
|
||||
return Keyword.add_root(**kwargs)
|
||||
kw = Keyword.add_root(**kwargs)
|
||||
return kw, True
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
@ -345,7 +346,7 @@ class Keyword(ExportModelOperationsMixin('keyword'), MP_Node, PermissionModelMix
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['space', 'name'], name='unique_name_per_space')
|
||||
]
|
||||
indexes = (Index(fields=['id', 'name']), )
|
||||
indexes = (Index(fields=['id', 'name']),)
|
||||
|
||||
|
||||
class Unit(ExportModelOperationsMixin('unit'), models.Model, PermissionModelMixin):
|
||||
@ -379,7 +380,7 @@ class Food(ExportModelOperationsMixin('food'), models.Model, PermissionModelMixi
|
||||
class Meta:
|
||||
# TODO according to this https://docs.djangoproject.com/en/3.1/ref/models/options/#unique-together should not be used
|
||||
unique_together = (('space', 'name'),)
|
||||
indexes = (Index(fields=['id', 'name']), )
|
||||
indexes = (Index(fields=['id', 'name']),)
|
||||
|
||||
|
||||
class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, PermissionModelMixin):
|
||||
@ -399,7 +400,7 @@ class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, Permiss
|
||||
|
||||
class Meta:
|
||||
ordering = ['order', 'pk']
|
||||
indexes = (Index(fields=['id', 'food', 'unit']), )
|
||||
indexes = (Index(fields=['id', 'food', 'unit']),)
|
||||
|
||||
|
||||
class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixin):
|
||||
@ -431,7 +432,7 @@ class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixi
|
||||
|
||||
class Meta:
|
||||
ordering = ['order', 'pk']
|
||||
indexes = (GinIndex(fields=["search_vector"]), )
|
||||
indexes = (GinIndex(fields=["search_vector"]),)
|
||||
|
||||
|
||||
class NutritionInformation(models.Model, PermissionModelMixin):
|
||||
@ -487,7 +488,7 @@ class Recipe(ExportModelOperationsMixin('recipe'), models.Model, PermissionModel
|
||||
return self.name
|
||||
|
||||
class Meta():
|
||||
indexes = (GinIndex(fields=["name_search_vector", "desc_search_vector"]), Index(fields=['id', 'name', 'description']), )
|
||||
indexes = (GinIndex(fields=["name_search_vector", "desc_search_vector"]), Index(fields=['id', 'name', 'description']),)
|
||||
|
||||
|
||||
class Comment(ExportModelOperationsMixin('comment'), models.Model, PermissionModelMixin):
|
||||
@ -538,7 +539,7 @@ class RecipeBook(ExportModelOperationsMixin('book'), models.Model, PermissionMod
|
||||
return self.name
|
||||
|
||||
class Meta():
|
||||
indexes = (Index(fields=['name', 'description']), )
|
||||
indexes = (Index(fields=['name', 'description']),)
|
||||
|
||||
|
||||
class RecipeBookEntry(ExportModelOperationsMixin('book_entry'), models.Model, PermissionModelMixin):
|
||||
@ -738,7 +739,7 @@ class CookLog(ExportModelOperationsMixin('cook_log'), models.Model, PermissionMo
|
||||
return self.recipe.name
|
||||
|
||||
class Meta():
|
||||
indexes = (Index(fields=['id', 'recipe', '-created_at', 'rating']), )
|
||||
indexes = (Index(fields=['id', 'recipe', '-created_at', 'rating']),)
|
||||
|
||||
|
||||
class ViewLog(ExportModelOperationsMixin('view_log'), models.Model, PermissionModelMixin):
|
||||
@ -753,7 +754,7 @@ class ViewLog(ExportModelOperationsMixin('view_log'), models.Model, PermissionMo
|
||||
return self.recipe.name
|
||||
|
||||
class Meta():
|
||||
indexes = (Index(fields=['recipe', '-created_at']), )
|
||||
indexes = (Index(fields=['recipe', '-created_at']),)
|
||||
|
||||
|
||||
class ImportLog(models.Model, PermissionModelMixin):
|
||||
|
Loading…
Reference in New Issue
Block a user