Exemple #1
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)
Exemple #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)
Exemple #3
0
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)
Exemple #4
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)
Exemple #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)