Make sure source is a User instance in relationship post_save signal

This commit is contained in:
Paul Osman 2010-12-19 19:27:01 -05:00
Родитель fcf96ac72d
Коммит daeb551481
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -10,6 +10,7 @@ from django.db import models, IntegrityError
from django.db.models.signals import post_save
from django.utils.translation import ugettext as _
from users.models import UserProfile
from drumbeat.models import ModelBase
log = logging.getLogger(__name__)
@ -119,7 +120,11 @@ def follow_handler(sender, **kwargs):
return
try:
import activity
activity.send(rel.source, 'follow', rel.target)
if isinstance(rel.source, UserProfile):
source = rel.source.user
else:
source = rel.source
activity.send(source, 'follow', rel.target)
except ImportError:
pass