gault-millau/apps/rating/tasks.py
Виктор Гладких f90e1ceded Add raiting
2019-10-03 11:37:59 +03:00

23 lines
464 B
Python

from datetime import timedelta
from celery import task
from rating.models import Rating
from django.contrib.contenttypes.models import ContentType
def add_rating(remote_addr, pk, model):
add.apply_async(
(remote_addr, pk, model), countdown=60
)
@task
def add(remote_addr, pk, model):
rating = Rating()
rating.ip = remote_addr
rating.object_id = pk
rating.content_type = ContentType.objects.get(model=model)
rating.save()