is check
This commit is contained in:
parent
d57429d9c6
commit
0cf975820a
|
@ -42,6 +42,7 @@ class TgItem(models.Model):
|
||||||
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)
|
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True, null=True, blank=True)
|
updated_at = models.DateTimeField(auto_now=True, null=True, blank=True)
|
||||||
tmc = models.ManyToManyField(TmcElement)
|
tmc = models.ManyToManyField(TmcElement)
|
||||||
|
is_check = models.BooleanField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Tg item {self.name}"
|
return f"Tg item {self.name}"
|
||||||
|
|
|
@ -148,7 +148,7 @@ class TgBot:
|
||||||
logger.info(f"Step {current_step} from user {user.full_name} with data {context.chat_data}")
|
logger.info(f"Step {current_step} from user {user.full_name} with data {context.chat_data}")
|
||||||
|
|
||||||
inv = []
|
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)})
|
inv.append({"name": e.name, "id": str(e.id)})
|
||||||
keys = chunk(1, inv)
|
keys = chunk(1, inv)
|
||||||
if len(inv) > 0:
|
if len(inv) > 0:
|
||||||
|
|
|
@ -131,7 +131,7 @@ class TmcStatViewset(viewsets.ViewSet):
|
||||||
def list(self, request):
|
def list(self, request):
|
||||||
if 'type' in request.query_params and request.query_params['type'] == 'location':
|
if 'type' in request.query_params and request.query_params['type'] == 'location':
|
||||||
queryset = (
|
queryset = (
|
||||||
TgItem.objects.all()
|
TgItem.objects.filter(is_check=True)
|
||||||
.values("location__parent")
|
.values("location__parent")
|
||||||
.annotate(
|
.annotate(
|
||||||
inv_count=Count("location__parent"),
|
inv_count=Count("location__parent"),
|
||||||
|
|
Loading…
Reference in New Issue