Audit Logs Package¶
Submodules¶
Models¶
-
class
seed.audit_logs.models.
AuditLog
(*args, **kwargs)¶ Bases:
django_extensions.db.models.TimeStampedModel
An audit log of events and notes. Inherits
created
andmodified
from TimeStampedModel-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
AuditLog.
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
AuditLog.
action_response
¶ A placeholder class that provides a way to set the attribute on the model.
-
AuditLog.
content_object
¶ Provide a generic many-to-one relation through the
content_type
andobject_id
fields.This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.
-
AuditLog.
content_type
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
AuditLog.
get_audit_type_display
(*moreargs, **morekwargs)¶
-
AuditLog.
get_next_by_created
(*moreargs, **morekwargs)¶
-
AuditLog.
get_next_by_modified
(*moreargs, **morekwargs)¶
-
AuditLog.
get_previous_by_created
(*moreargs, **morekwargs)¶
-
AuditLog.
get_previous_by_modified
(*moreargs, **morekwargs)¶
-
AuditLog.
objects
= <seed.audit_logs.models.AuditLogManager object>¶
-
AuditLog.
organization
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
AuditLog.
save
(*args, **kwargs)¶ Ensure that only notes are saved
-
AuditLog.
to_dict
()¶ serializes an audit_log
-
AuditLog.
user
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
exception
Tests¶
-
class
seed.audit_logs.tests.
AuditLogModelTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
-
setUp
()¶
-
test_audit
()¶ tests audit save
-
test_audit_save
()¶ audit_log
LOG
should not be able to save/update
-
test_audit_update
()¶ audit_log
LOG
should not be able to save/update
-
test_generic_relation
()¶ test CanonicalBuilding.audit_logs
-
test_get_all_audit_logs_for_an_org
()¶ gets all audit logs for an org
-
test_model___unicode__
()¶ tests the AuditLog inst. str or unicode
-
test_note
()¶ tests note save
-
test_note_save
()¶ notes should be able to save/update
-
URLs¶
Views¶
-
seed.audit_logs.views.
create_note
(request, *args, **kwargs)¶ Retrieves logs for a building.
POST: Expects the CanonicalBuildings’s id in the JSON payload as building_id. Expects an organization_id (to which project belongs) in the query string. Expects the action_note to be in the JSON payload as action_note Returns:
'audit_log' : { 'user': { 'first_name': user's firstname, 'last_name': user's last_name, 'id': user's id, 'email': user's email address }, 'id': audit log's id, 'audit_type': 'Note', 'created': DateTime, 'modified': DateTime, 'action': method triggering log entry, 'action_response': response of action, 'action_note': the note body 'organization': { 'name': name of org, 'id': id of org }, 'status': 'success'
-
seed.audit_logs.views.
get_building_logs
(request, *args, **kwargs)¶ Retrieves logs for a building.
GET: Expects the CanonicalBuildings’s id in the query string as building_id. Expects an organization_id (to which project belongs) in the query string. Returns:
'audit_logs' : [ { 'user': { 'first_name': user's firstname, 'last_name': user's last_name, 'id': user's id, 'email': user's email address }, 'id': audit log's id, 'audit_type': 'Log' or 'Note', 'created': DateTime, 'modified': DateTime, 'action': method triggering log entry, 'action_response': response of action, 'action_note': the note body if Note or further description 'organization': { 'name': name of org, 'id': id of org } }, ... ], 'status': 'success'
-
seed.audit_logs.views.
update_note
(request, *args, **kwargs)¶ Retrieves logs for a building.
PUT: Expects the CanonicalBuildings’s id in the JSON payload as building_id. Expects an organization_id (to which project belongs) in the query string. Expects the action_note to be in the JSON payload as action_note Expects the audit_log_id to be in the JSON payload as audit_log_id Returns:
'audit_log' : { 'user': { 'first_name': user's firstname, 'last_name': user's last_name, 'id': user's id, 'email': user's email address }, 'id': audit log's id, 'audit_type': 'Note', 'created': DateTime, 'modified': DateTime, 'action': method triggering log entry, 'action_response': response of action, 'action_note': the note body 'organization': { 'name': name of org, 'id': id of org }, 'status': 'success'