Fix up some bugs with signal handling related to association/disassociation

This commit is contained in:
Matthew Jones
2013-11-08 13:08:48 -05:00
parent f4e3613244
commit c48e4745bf
2 changed files with 5 additions and 4 deletions

View File

@@ -18,11 +18,11 @@ class ActivityStream(models.Model):
('update', _("Entity Updated")), ('update', _("Entity Updated")),
('delete', _("Entity Deleted")), ('delete', _("Entity Deleted")),
('associate', _("Entity Associated with another Entity")), ('associate', _("Entity Associated with another Entity")),
('disaassociate', _("Entity was Disassociated with another Entity")) ('disassociate', _("Entity was Disassociated with another Entity"))
] ]
user = models.ForeignKey('auth.User', null=True, on_delete=models.SET_NULL, related_name='activity_stream') user = models.ForeignKey('auth.User', null=True, on_delete=models.SET_NULL, related_name='activity_stream')
operation = models.CharField(max_length=9, choices=OPERATION_CHOICES) operation = models.CharField(max_length=13, choices=OPERATION_CHOICES)
timestamp = models.DateTimeField(auto_now_add=True) timestamp = models.DateTimeField(auto_now_add=True)
changes = models.TextField(blank=True) changes = models.TextField(blank=True)

View File

@@ -4,6 +4,7 @@
# Python # Python
import logging import logging
import threading import threading
import json
# Django # Django
from django.db.models.signals import pre_save, post_save, pre_delete, post_delete, m2m_changed from django.db.models.signals import pre_save, post_save, pre_delete, post_delete, m2m_changed
@@ -215,8 +216,8 @@ def activity_stream_associate(sender, instance, **kwargs):
obj1_id = obj1.id obj1_id = obj1.id
obj_rel = str(sender) obj_rel = str(sender)
for entity_acted in kwargs['pk_set']: for entity_acted in kwargs['pk_set']:
obj2 = entity_acted obj2 = kwargs['model']
obj2_id = entity_acted.id obj2_id = entity_acted
activity_entry = ActivityStream( activity_entry = ActivityStream(
operation=action, operation=action,
object1_id=obj1_id, object1_id=obj1_id,