From 5d8ebc513ae3b78975da628adbf8ba817382173d Mon Sep 17 00:00:00 2001 From: smilerz Date: Fri, 13 Aug 2021 11:23:47 -0500 Subject: [PATCH] minor cleanup --- cookbook/helper/recipe_search.py | 2 +- cookbook/helper/scrapers/scrapers.py | 1 - cookbook/managers.py | 3 --- cookbook/models.py | 25 +++++++++++-------- cookbook/schemas.py | 1 - .../apps/KeywordListView/KeywordListView.vue | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cookbook/helper/recipe_search.py b/cookbook/helper/recipe_search.py index fcd7e1a8b..f1a083fed 100644 --- a/cookbook/helper/recipe_search.py +++ b/cookbook/helper/recipe_search.py @@ -127,7 +127,7 @@ def search_recipes(request, queryset, params): # TODO creating setting to include descendants of keywords a setting if search_keywords_or == 'true': # when performing an 'or' search all descendants are included in the OR condition - # so descendants are appended to + # so descendants are appended to filter all at once for kw in Keyword.objects.filter(pk__in=search_keywords): search_keywords += list(kw.get_descendants().values_list('pk', flat=True)) queryset = queryset.filter(keywords__id__in=search_keywords) diff --git a/cookbook/helper/scrapers/scrapers.py b/cookbook/helper/scrapers/scrapers.py index 4c41474e5..6d785a5ef 100644 --- a/cookbook/helper/scrapers/scrapers.py +++ b/cookbook/helper/scrapers/scrapers.py @@ -30,7 +30,6 @@ def text_scraper(text, url=None): url=None ): self.wild_mode = False - # self.exception_handling = None # TODO add new method here, old one was deprecated self.meta_http_equiv = False self.soup = BeautifulSoup(page_data, "html.parser") self.url = url diff --git a/cookbook/managers.py b/cookbook/managers.py index 040cc9ad1..76b01f961 100644 --- a/cookbook/managers.py +++ b/cookbook/managers.py @@ -6,7 +6,6 @@ from django.db import models from django.db.models import Q from django.utils import translation -# TODO move this somewhere else and delete this file DICTIONARY = { # TODO find custom dictionaries - maybe from here https://www.postgresql.org/message-id/CAF4Au4x6X_wSXFwsQYE8q5o0aQZANrvYjZJ8uOnsiHDnOVPPEg%40mail.gmail.com # 'hy': 'Armenian', @@ -22,8 +21,6 @@ DICTIONARY = { } -# TODO add search highlighting -# TODO add language support # TODO add schedule index rebuild class RecipeSearchManager(models.Manager): def search(self, search_text, space): diff --git a/cookbook/models.py b/cookbook/models.py index f0b199df2..2197e36b7 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -228,8 +228,9 @@ class SupermarketCategory(models.Model, PermissionModelMixin): return self.name 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'),) + constraints = [ + models.UniqueConstraint(fields=['space', 'name'], name='unique_name_per_space') + ] class Supermarket(models.Model, PermissionModelMixin): @@ -244,8 +245,9 @@ class Supermarket(models.Model, PermissionModelMixin): return self.name 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'),) + constraints = [ + models.UniqueConstraint(fields=['space', 'name'], name='unique_name_per_space') + ] class SupermarketCategoryRelation(models.Model, PermissionModelMixin): @@ -359,8 +361,9 @@ class Unit(ExportModelOperationsMixin('unit'), models.Model, PermissionModelMixi return self.name 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'),) + constraints = [ + models.UniqueConstraint(fields=['space', 'name'], name='unique_name_per_space') + ] class Food(ExportModelOperationsMixin('food'), models.Model, PermissionModelMixin): @@ -377,8 +380,9 @@ class Food(ExportModelOperationsMixin('food'), models.Model, PermissionModelMixi return self.name 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'),) + constraints = [ + models.UniqueConstraint(fields=['space', 'name'], name='unique_name_per_space') + ] indexes = (Index(fields=['id', 'name']),) @@ -562,8 +566,9 @@ class RecipeBookEntry(ExportModelOperationsMixin('book_entry'), models.Model, Pe return None class Meta: - # TODO according to this https://docs.djangoproject.com/en/3.1/ref/models/options/#unique-together should not be used - unique_together = (('recipe', 'book'),) + constraints = [ + models.UniqueConstraint(fields=['recipe', 'book'], name='unique_name_per_space') + ] class MealType(models.Model, PermissionModelMixin): diff --git a/cookbook/schemas.py b/cookbook/schemas.py index 510136093..6f5dab703 100644 --- a/cookbook/schemas.py +++ b/cookbook/schemas.py @@ -62,7 +62,6 @@ class RecipeSchema(AutoSchema): return parameters -# TODO move to separate class to cleanup class TreeSchema(AutoSchema): def get_path_parameters(self, path, method): diff --git a/vue/src/apps/KeywordListView/KeywordListView.vue b/vue/src/apps/KeywordListView/KeywordListView.vue index 54321e5e2..4a6d00a10 100644 --- a/vue/src/apps/KeywordListView/KeywordListView.vue +++ b/vue/src/apps/KeywordListView/KeywordListView.vue @@ -6,7 +6,7 @@
- +