From 0cf975820a45beed125861e0551afffa74ad7035 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Thu, 22 Aug 2024 16:54:56 +0300 Subject: [PATCH] is check --- back/tgbot/models.py | 1 + back/tgbot/tgbot.py | 2 +- back/tgbot/views.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/back/tgbot/models.py b/back/tgbot/models.py index 22f6d03..98b67c1 100644 --- a/back/tgbot/models.py +++ b/back/tgbot/models.py @@ -42,6 +42,7 @@ class TgItem(models.Model): created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) tmc = models.ManyToManyField(TmcElement) + is_check = models.BooleanField() def __str__(self): return f"Tg item {self.name}" diff --git a/back/tgbot/tgbot.py b/back/tgbot/tgbot.py index 7f9053b..6607ea6 100644 --- a/back/tgbot/tgbot.py +++ b/back/tgbot/tgbot.py @@ -148,7 +148,7 @@ class TgBot: logger.info(f"Step {current_step} from user {user.full_name} with data {context.chat_data}") inv = [] - async for e in TgItem.objects.filter(user_id=user.id).order_by('-created_at'): + async for e in TgItem.objects.filter(user_id=user.id, is_check=False).order_by('-created_at'): inv.append({"name": e.name, "id": str(e.id)}) keys = chunk(1, inv) if len(inv) > 0: diff --git a/back/tgbot/views.py b/back/tgbot/views.py index 27f5ab7..ce8b184 100644 --- a/back/tgbot/views.py +++ b/back/tgbot/views.py @@ -131,7 +131,7 @@ class TmcStatViewset(viewsets.ViewSet): def list(self, request): if 'type' in request.query_params and request.query_params['type'] == 'location': queryset = ( - TgItem.objects.all() + TgItem.objects.filter(is_check=True) .values("location__parent") .annotate( inv_count=Count("location__parent"),