mirror of
https://github.com/ae-utbm/sith.git
synced 2025-09-16 13:03:51 +00:00
ScheduledProductAction
model to store tasks related to products
This commit is contained in:
@@ -2,12 +2,19 @@
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
from counter.models import Product
|
||||
from counter.models import Counter, Product
|
||||
|
||||
|
||||
@shared_task
|
||||
def archive_product(product_id):
|
||||
def archive_product(*, product_id: int):
|
||||
product = Product.objects.get(id=product_id)
|
||||
product.archived = True
|
||||
product.save()
|
||||
product.counters.clear()
|
||||
|
||||
|
||||
@shared_task
|
||||
def change_counters(*, product_id: int, counters: list[int]):
|
||||
product = Product.objects.get(id=product_id)
|
||||
counters = Counter.objects.filter(id__in=counters)
|
||||
product.counters.set(counters)
|
||||
|
Reference in New Issue
Block a user