def new_content_birth(sender, **kwargs): """ Record a new Timeline entry and also a ContentTimeline entry when a new Content object is created. 'sender' should be a subclass of Content. """ # Ignore updates to existing objects. created = kwargs['created'] if not created: return # Get the content object actually being saved. instance = kwargs['instance'] content = instance.content_ptr # Get admin user. admin = User.objects.get(pk=1) # Create event on timeline. event = Timeline() event.user = admin event.comment = "%s was born" % content event.save() # Create a ContentTimeline entry. life = ContentTimeline() life.content = content life.born = event life.save()
def record_content_change(sender, **kwargs): """ Record a timeline entry when a Content item is added or updated. We're keeping this for an example, for the moment. """ # Get the content object actually being saved. content = kwargs['instance'] # Save a different message for insertion vs. update. created = kwargs['created'] if created: comment = 'Created %s from %s' % (content.get_app_model(), sender) else: comment = 'Updated %s from %s' % (content.get_app_model(), sender) # Get admin user. admin = User.objects.get(pk=1) # Create event on timeline. event = Timeline() event.user = admin event.comment = comment event.save()