fixed wsgi error

This commit is contained in:
smilerz
2021-09-28 15:45:54 -05:00
parent 39255c93a5
commit b7b0b9c690
3 changed files with 18 additions and 16 deletions

View File

@@ -43,8 +43,7 @@ class TreeManager(MP_NodeManager):
try:
return self.get(name__exact=kwargs['name'], space=kwargs['space']), False
except self.model.DoesNotExist:
with scopes_disabled():
return self.model.add_root(**kwargs), True
return self.model.add_root(**kwargs), True
class TreeModel(MP_Node):
@@ -353,6 +352,13 @@ class Keyword(ExportModelOperationsMixin('keyword'), TreeModel, PermissionModelM
indexes = (Index(fields=['id', 'name']),)
# when starting up run fix_tree to:
# a) make sure that nodes are sorted when switching between sort modes
# b) fix problems, if any, with tree consistency
with scopes_disabled():
Keyword.fix_tree(fix_paths=True)
class Unit(ExportModelOperationsMixin('unit'), models.Model, PermissionModelMixin):
name = models.CharField(max_length=128, validators=[MinLengthValidator(1)])
description = models.TextField(blank=True, null=True)
@@ -400,6 +406,13 @@ class Food(ExportModelOperationsMixin('food'), TreeModel, PermissionModelMixin):
)
# when starting up run fix_tree to:
# a) make sure that nodes are sorted when switching between sort modes
# b) fix problems, if any, with tree consistency
with scopes_disabled():
Food.fix_tree(fix_paths=True)
class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, PermissionModelMixin):
# a pre-delete signal on Food checks if the Ingredient is part of a Step, if it is raises a ProtectedError instead of cascading the delete
food = models.ForeignKey(Food, on_delete=models.CASCADE, null=True, blank=True)
@@ -793,7 +806,7 @@ class ViewLog(ExportModelOperationsMixin('view_log'), models.Model, PermissionMo
class Meta():
indexes = (
Index(fields=['recipe']),
Index(fields=[ '-created_at']),
Index(fields=['-created_at']),
Index(fields=['created_by']),
Index(fields=['recipe', '-created_at', 'created_by']),
)