make 'name' unique in space for MealType

make MealType, Unit, Supermarket, Supermarket Category, PropoertyType
case insenstive for get_or_create
convert unit conversion create serializer to get_or_create behavior
enable create duplicate tests for unitconversion and mealtype api
This commit is contained in:
smilerz
2023-09-14 14:46:37 -05:00
parent 6dacd44f1f
commit a7795092b3
5 changed files with 106 additions and 57 deletions

View File

@@ -982,6 +982,11 @@ class MealType(models.Model, PermissionModelMixin):
def __str__(self):
return self.name
class Meta:
constraints = [
models.UniqueConstraint(fields=['space', 'name'], name='mt_unique_name_per_space'),
]
class MealPlan(ExportModelOperationsMixin('meal_plan'), models.Model, PermissionModelMixin):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, blank=True, null=True)