(verb, **kwargs)
return newaction
Handler function to create Action instance upon action signal call.
Handler function to create Action instance upon action signal call.
Handler function to create Action instance upon action signal call .
def action_handler(verb, **kwargs):
    """
    Handler function to create Action instance upon action signal call.
    """
    kwargs.pop('signal', None)
    actor = kwargs.pop('sender')

    # We must store the unstranslated string
    # If verb is an ugettext_lazyed string, fetch the original string
    if hasattr(verb, '_proxy____args'):
        verb = verb._proxy____args[0]

    newaction = apps.get_model('actstream', 'action')(
        actor_content_type=ContentType.objects.get_for_model(actor),
        actor_object_id=actor.pk,
        verb=str(verb),
        public=bool(kwargs.pop('public', True)),
        description=kwargs.pop('description', None),
        timestamp=kwargs.pop('timestamp', now())
    )

    for opt in ('target', 'action_object'):
        obj = kwargs.pop(opt, None)
        if obj is not None:
            check(obj)
            setattr(newaction, '%s_object_id' % opt, obj.pk)
            setattr(newaction, '%s_content_type' % opt,
                    ContentType.objects.get_for_model(obj))
    if settings.USE_JSONFIELD and len(kwargs):
        newaction.data = kwargs
    newaction.save(force_insert=True)
    return newaction
def action_handler ( verb , * * kwargs ) : kwargs . pop ( 'signal' , None ) actor = kwargs . pop ( 'sender' ) # We must store the unstranslated string # If verb is an ugettext_lazyed string, fetch the original string if hasattr ( verb , '_proxy____args' ) : verb = verb . _proxy____args [ 0 ] newaction = apps . get_model ( 'actstream' , 'action' ) ( actor_content_type = ContentType . objects . get_for_model ( actor ) , actor_object_id = actor . pk , verb = str ( verb ) , public = bool ( kwargs . pop ( 'public' , True ) ) , description = kwargs . pop ( 'description' , None ) , timestamp = kwargs . pop ( 'timestamp' , now ( ) ) ) for opt in ( 'target' , 'action_object' ) : obj = kwargs . pop ( opt , None ) if obj is not None : check ( obj ) setattr ( newaction , '%s_object_id' % opt , obj . pk ) setattr ( newaction , '%s_content_type' % opt , ContentType . objects . get_for_model ( obj ) ) if settings . USE_JSONFIELD and len ( kwargs ) : newaction . data = kwargs newaction . save ( force_insert = True ) return newaction