23 lines
523 B
Python
23 lines
523 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, app_label):
|
|
add.apply_async(
|
|
(remote_addr, pk, model, app_label), countdown=60 * 60
|
|
)
|
|
|
|
|
|
@task
|
|
def add(remote_addr, pk, model, app_label):
|
|
rating = Rating()
|
|
rating.ip = remote_addr
|
|
rating.object_id = pk
|
|
rating.content_type = ContentType.objects.get(app_label=app_label, model=model)
|
|
rating.save()
|
|
|
|
|
|
|