django-simple-audit


Namedjango-simple-audit JSON
Version 0.1.22 PyPI version JSON
download
home_pagehttps://github.com/leandrosouza/django-simple-audit
SummarySimple audit for model instances in Django.
upload_time2017-02-20 14:11:08
maintainerNone
docs_urlNone
authorLeandro Souza
requires_pythonNone
licenseBSD
keywords revisions versioning history audit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
Coveralis test coverage No Coveralis.
            ****************************************
django simple audit
****************************************
This applications was created to audit model's changes and maintain a log of them


Installation
===============
You can install django-simple-audit in 2 ways: using pip or by setup.py install

.. code-block:: bash

    $ pip install django-simple-audit


Then modify your settings.py, adding the package `simple_audit` in INSTALLED_APPS and in MIDDLEWARE_CLASSES add
`simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware`:

.. code-block:: bash

	INSTALLED_APPS = (
	    '...',
	    'simple_audit',
	)

	MIDDLEWARE_CLASSES = (
	     '...',
	     'simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware',
	)

	DJANGO_SIMPLE_AUDIT_ACTIVATED = True

Usage
======

Tracking changes on a model
----------------------------

to audit a model you need import `simple_audit` and then register the model to be audited.

.. code-block:: python

	from django.db import models
	import simple_audit


	class Message(models.Model):

	    title = models.CharField(max_length=50, blank=False)
	    text = models.TextField(blank=False)

	    def __unicode__(self):
	        return self.text


	class Owner(models.Model):

	    name = models.CharField(max_length=50, blank=False)

	    def __unicode__(self):
	        return self.name


	class VirtualMachine(models.Model):

	    name = models.CharField(max_length=50, blank=False)
	    cpus = models.IntegerField()
	    owner = models.ForeignKey(Owner)
	    so = models.CharField(max_length=100, blank=False)
	    started = models.BooleanField()

	    def __unicode__(self):
	        return self.name


	simple_audit.register(Message, Owner, VirtualMachine)

Advanced Usage (without httprequest or our middleware)
--------------------------------------------------------

You can use django-simple-audit without an http request (for example in management command). In this situation
there is no http request on thread context. To ensure gathering all modification on a single AuditRequest, you can
specify it:

.. code-block:: python

	AuditRequest.new_request(path, user, ip)
	try:
	    # my code... in same thread
	finally:
	    AuditRequest.cleanup_request()

Tracking m2m fields changes
----------------------------

Tracking m2m fields changes is still experimental, but you can enable it with the following variable:

    DJANGO_SIMPLE_AUDIT_M2M_FIELDS = True

You need to have at least one cache backend set in your django settings, otherwise the previous settings will be set to False.

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'unique',
            'TIMEOUT': 300,
        }
    }

Dependencies
============

* Django >= 1.4.x
* django.contrib.contenttypes installed in INSTALLED_APPS


TODO
====
* Improve tests

CHANGELOG
=========
* 0.1.21
	* Problems with upload to pypi ( the version was used ) - Sux 

* 0.1.20
        * Add .get_queryset to AuditManager ( thanks sburns )

* 0.1.19
	* Tracking user from Django REST Framework authentication ( thanks jnishiyama )

* 0.1.15
	* use larger TextField for storing values ( thanks dinie )
	* Czech translation ( thanks cuchac )

* 0.1.14
	* improved m2m audit feature ( thanks dinie )
    * Add support for Custom user model ( thanks dinie )
    * Option to turn on/off auditing ( thanks dinie )

* 0.1.12
    * Created some simple tests
    * Enable many to many fiedls tracking (see Usage)
            

Raw data

            {
    "maintainer": null, 
    "docs_url": null, 
    "requires_python": null, 
    "maintainer_email": null, 
    "cheesecake_code_kwalitee_id": null, 
    "coveralis": false, 
    "keywords": "revisions versioning history audit", 
    "upload_time": "2017-02-20 14:11:08", 
    "author": "Leandro Souza", 
    "home_page": "https://github.com/leandrosouza/django-simple-audit", 
    "github_user": "leandrosouza", 
    "download_url": "https://pypi.python.org/packages/d5/b5/ce6973ef48091f8c12e32a4c9f21da0ff0b74f210eb5d21530a6cde69073/django-simple-audit-0.1.22.tar.gz", 
    "platform": "UNKNOWN", 
    "version": "0.1.22", 
    "cheesecake_documentation_id": null, 
    "description": "****************************************\ndjango simple audit\n****************************************\nThis applications was created to audit model's changes and maintain a log of them\n\n\nInstallation\n===============\nYou can install django-simple-audit in 2 ways: using pip or by setup.py install\n\n.. code-block:: bash\n\n    $ pip install django-simple-audit\n\n\nThen modify your settings.py, adding the package `simple_audit` in INSTALLED_APPS and in MIDDLEWARE_CLASSES add\n`simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware`:\n\n.. code-block:: bash\n\n\tINSTALLED_APPS = (\n\t    '...',\n\t    'simple_audit',\n\t)\n\n\tMIDDLEWARE_CLASSES = (\n\t     '...',\n\t     'simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware',\n\t)\n\n\tDJANGO_SIMPLE_AUDIT_ACTIVATED = True\n\nUsage\n======\n\nTracking changes on a model\n----------------------------\n\nto audit a model you need import `simple_audit` and then register the model to be audited.\n\n.. code-block:: python\n\n\tfrom django.db import models\n\timport simple_audit\n\n\n\tclass Message(models.Model):\n\n\t    title = models.CharField(max_length=50, blank=False)\n\t    text = models.TextField(blank=False)\n\n\t    def __unicode__(self):\n\t        return self.text\n\n\n\tclass Owner(models.Model):\n\n\t    name = models.CharField(max_length=50, blank=False)\n\n\t    def __unicode__(self):\n\t        return self.name\n\n\n\tclass VirtualMachine(models.Model):\n\n\t    name = models.CharField(max_length=50, blank=False)\n\t    cpus = models.IntegerField()\n\t    owner = models.ForeignKey(Owner)\n\t    so = models.CharField(max_length=100, blank=False)\n\t    started = models.BooleanField()\n\n\t    def __unicode__(self):\n\t        return self.name\n\n\n\tsimple_audit.register(Message, Owner, VirtualMachine)\n\nAdvanced Usage (without httprequest or our middleware)\n--------------------------------------------------------\n\nYou can use django-simple-audit without an http request (for example in management command). In this situation\nthere is no http request on thread context. To ensure gathering all modification on a single AuditRequest, you can\nspecify it:\n\n.. code-block:: python\n\n\tAuditRequest.new_request(path, user, ip)\n\ttry:\n\t    # my code... in same thread\n\tfinally:\n\t    AuditRequest.cleanup_request()\n\nTracking m2m fields changes\n----------------------------\n\nTracking m2m fields changes is still experimental, but you can enable it with the following variable:\n\n    DJANGO_SIMPLE_AUDIT_M2M_FIELDS = True\n\nYou need to have at least one cache backend set in your django settings, otherwise the previous settings will be set to False.\n\n    CACHES = {\n        'default': {\n            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',\n            'LOCATION': 'unique',\n            'TIMEOUT': 300,\n        }\n    }\n\nDependencies\n============\n\n* Django >= 1.4.x\n* django.contrib.contenttypes installed in INSTALLED_APPS\n\n\nTODO\n====\n* Improve tests\n\nCHANGELOG\n=========\n* 0.1.21\n\t* Problems with upload to pypi ( the version was used ) - Sux \n\n* 0.1.20\n        * Add .get_queryset to AuditManager ( thanks sburns )\n\n* 0.1.19\n\t* Tracking user from Django REST Framework authentication ( thanks jnishiyama )\n\n* 0.1.15\n\t* use larger TextField for storing values ( thanks dinie )\n\t* Czech translation ( thanks cuchac )\n\n* 0.1.14\n\t* improved m2m audit feature ( thanks dinie )\n    * Add support for Custom user model ( thanks dinie )\n    * Option to turn on/off auditing ( thanks dinie )\n\n* 0.1.12\n    * Created some simple tests\n    * Enable many to many fiedls tracking (see Usage)", 
    "lcname": "django-simple-audit", 
    "bugtrack_url": null, 
    "github": true, 
    "name": "django-simple-audit", 
    "license": "BSD", 
    "travis_ci": false, 
    "github_project": "django-simple-audit", 
    "summary": "Simple audit for model instances in Django.", 
    "split_keywords": [
        "revisions", 
        "versioning", 
        "history", 
        "audit"
    ], 
    "author_email": "lsouzarj@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-02-20T14:11:08", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/d5/b5/ce6973ef48091f8c12e32a4c9f21da0ff0b74f210eb5d21530a6cde69073/django-simple-audit-0.1.22.tar.gz", 
            "md5_digest": "65a0725bfac3a8decc21b2d864d77eca", 
            "downloads": 0, 
            "filename": "django-simple-audit-0.1.22.tar.gz", 
            "packagetype": "sdist", 
            "path": "d5/b5/ce6973ef48091f8c12e32a4c9f21da0ff0b74f210eb5d21530a6cde69073/django-simple-audit-0.1.22.tar.gz", 
            "size": 14345
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}