ScheduledProductAction model to store tasks related to products

This commit is contained in:
imperosol
2025-09-14 21:47:51 +02:00
parent dc4e01ff9c
commit 5ee8d3b434
3 changed files with 80 additions and 2 deletions

View File

@@ -2,11 +2,18 @@
from celery import shared_task
from counter.models import Product
from counter.models import Counter, Product
@shared_task
def archive_product(product_id: int):
def archive_product(*, product_id: int, **kwargs):
product = Product.objects.get(id=product_id)
product.archived = True
product.save()
@shared_task
def change_counters(*, product_id: int, counters: list[int], **kwargs):
product = Product.objects.get(id=product_id)
counters = Counter.objects.filter(id__in=counters)
product.counters.set(counters)