mirror of
https://github.com/ae-utbm/sith.git
synced 2025-10-09 08:14:39 +00:00
20 lines
490 B
Python
20 lines
490 B
Python
# Create your tasks here
|
|
|
|
from celery import shared_task
|
|
|
|
from counter.models import Counter, Product
|
|
|
|
|
|
@shared_task
|
|
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)
|