Anonymous avatar Anonymous committed 7a0162b

Initial checkin

Comments (0)

Files changed (8)

+~$
+pyc$

Empty file added.

audittrail/admin.py

+from django.contrib import admin
+from audittrail import models
+
+class AuditAdmin(admin.ModelAdmin):
+     list_display = ('created', 'user', 'action', 'details',)
+     list_filter = ('created', 'user',)
+     date_hierarchy = 'created'
+
+admin.site.register(models.Audit, AuditAdmin)

audittrail/middleware.py

+from audittrail.models import Audit
+
+class AuditHandler(object):
+    def __init__(self, request):
+        self.user = request.user
+
+    def log(self, action, details=None):
+        if details is None:
+            details = ''
+        Audit.objects.create(
+            user=self.user,
+            action=action,
+            details=details
+        )
+
+class AuditMiddleware(object):
+    def process_request(self, request):
+        '''Add the Audit interface to request'''
+        if not hasattr(request, 'audit'):
+            setattr(request, 'audit', AuditHandler(request))

audittrail/models.py

+from django.db import models
+from datetime import datetime
+
+class Audit(models.Model):
+    '''Audit trail for Student activity'''
+    created = models.DateTimeField(default=datetime.now)
+    user = models.ForeignKey('auth.User')
+    action = models.CharField(max_length=1024)
+    details = models.TextField(blank=True)
+
+    def __unicode__(self):
+        return u'[%s] %s: %s' % (self.created, self.user.get_full_name(), self.action)
+
+    class Meta:
+        ordering = ('-created',)
+        verbose_name = 'Audit Log'
+        verbose_name_plural = 'Audit Logs'

audittrail/test.py

+from django.utils import unittest
+
+

Empty file added.

+from setuptools import setup, find_packages
+
+setup( name='gnocchi-cms',
+    version = '0.1',
+    description = 'A simple audit log tool',
+    author = 'Curtis Maloney',
+    author_email = 'curtis@tinbrain.net',
+    url = 'http://bitbucket.org/funkybob/django-auduttrail/',
+    keywords = ['django',],
+    packages = find_packages(),
+    include_package_data = True,
+    zip_safe = False,
+    classifiers = [
+        'Environment :: Web Environment',
+        'Framework :: Django',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+    ],
+    install_requires = [
+        'Django>=1.3',
+    ]
+)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.