23 lines
464 B
Python
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()
|
|
|
|
|
|
|