Esempio n. 1
0
def action_handler(verb, target=None, public=True, **kwargs):
    actor = kwargs.pop('sender')
    kwargs.pop('signal', None)
    action = Action(actor_content_type=ContentType.objects.get_for_model(actor),
                    actor_object_id=actor.pk,
                    verb=unicode(verb),
                    public=bool(public))
    if target:
        action.target_object_id=target.pk
        action.target_content_type=ContentType.objects.get_for_model(target)

    action.save()
Esempio n. 2
0
def action_handler(verb, target=None, public=True, **kwargs):
    actor = kwargs.pop('sender')
    kwargs.pop('signal', None)
    action = Action(
        actor_content_type=ContentType.objects.get_for_model(actor),
        actor_object_id=actor.pk,
        verb=unicode(verb),
        public=bool(public))
    if target:
        action.target_object_id = target.pk
        action.target_content_type = ContentType.objects.get_for_model(target)

    action.save()
Esempio n. 3
0
def action_handler(verb, target=None, object=None, **kwargs):
    actor = kwargs.pop('sender')
    kwargs.pop('signal', None)
    action = Action(actor_content_type=ContentType.objects.get_for_model(actor),
                    actor_object_id=actor.pk,
                    verb=unicode(verb),
                    public=bool(kwargs.pop('public', True)),
                    description=kwargs.pop('description', None),
                    timestamp=kwargs.pop('timestamp', datetime.now()))
    
    if target:
        action.target_object_id=target.pk
        action.target_content_type=ContentType.objects.get_for_model(target)
    
    if object:
        action.object_object_id=object.pk
        action.object_content_type=ContentType.objects.get_for_model(object)
        
    action.save()
Esempio n. 4
0
 def test_hidden_action(self):
     action = self.user1.actor_actions.all()[0]
     action.public = False
     action.save()
     self.assert_(not action in self.user1.actor_actions.public())