コード例 #1
0
ファイル: signals.py プロジェクト: unicefuganda/auditcare
def couch_audit_save(instance, *args, **kwargs):
    instance.__orig_save(*args, **kwargs)
    instance_json = instance.to_json()
    from auditcare.models import AuditEvent
    usr = get_current_user()
    if usr != None:
        try:
            User.objects.get(id=usr.id)
        except:
            usr = None
    AuditEvent.audit_couch_save(instance.__class__, instance, instance_json, usr)
コード例 #2
0
def couch_audit_save(instance, *args, **kwargs):
    instance.__orig_save(*args, **kwargs)
    instance_json = instance.to_json()
    from auditcare.models import AuditEvent
    usr = get_current_user()
    if usr != None:
        try:
            User.objects.get(id=usr.id)
        except:
            usr = None
    AuditEvent.audit_couch_save(instance.__class__, instance, instance_json, usr)
コード例 #3
0
ファイル: signals.py プロジェクト: unicefuganda/auditcare
def django_audit_save(sender, instance, created, **kwargs):
    """
    Audit Save is a signal to attach post_save to any arbitrary django model
    """
    usr = get_current_user()

    # a silly wrap the instance in an array to serialize it, then pull it out of the array to get the json data standalone
    instance_json = json.loads(json_serializer.serialize([instance], ensure_ascii=False))[0]['fields']

    #really stupid sanity check for unit tests when threadlocals doesn't update and user model data is updated.
    if usr != None:
        try:
            User.objects.get(id=usr.id)
        except:
            usr = None
    from auditcare.models import AuditEvent
    AuditEvent.audit_django_save(sender, instance, instance_json, usr)
コード例 #4
0
ファイル: signals.py プロジェクト: dimagi/auditcare
def django_audit_save(sender, instance, created, raw=False, **kwargs):
    """
    Audit Save is a signal to attach post_save to any arbitrary django model
    """
    if raw:
        return

    usr = get_current_user()

    instance_json = model_to_json(instance)

    #really stupid sanity check for unit tests when threadlocals doesn't update and user model data is updated.
    if usr != None:
        try:
            User.objects.get(id=usr.id)
        except:
            usr = None
    from auditcare.models import AuditEvent
    AuditEvent.audit_django_save(sender, instance, instance_json, usr)
コード例 #5
0
def django_audit_save(sender, instance, created, raw=False, **kwargs):
    """
    Audit Save is a signal to attach post_save to any arbitrary django model
    """
    if raw:
        return

    usr = get_current_user()

    instance_json = model_to_json(instance)

    #really stupid sanity check for unit tests when threadlocals doesn't update and user model data is updated.
    if usr != None:
        try:
            User.objects.get(id=usr.id)
        except:
            usr = None
    from auditcare.models import AuditEvent
    AuditEvent.audit_django_save(sender, instance, instance_json, usr)