Skip to content

Commit

Permalink
Python3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
soynatan committed Oct 23, 2016
1 parent fa91360 commit f366bf6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ a registry. This applies to every model of every app in your project.
When any of these events takes place, django-easy-audit will log it in the model `CRUDEvent`.
You can query this information in the Django Admin app.

Besides logging CRUD events, django-easy-audit will log every time your users log in, out,
Besides logging CRUD events, django-easy-audit will log every time a user logs in, out,
or fails to log in. This information is stored in the model `LoginEvent`.

## Why should I use it
Expand All @@ -55,7 +55,7 @@ them inherit from a certain class. Other apps create a mirror for each of your m
duplicate migrations. Etc.

It is not that they don't work or that they are not great apps. But in case you need something
easier, and you don't want your project to depend so much on a third party app, django-easy-audit
easier, and you don't want your project to depend so much on a third-party app, django-easy-audit
may be your best choice.

The good thing about this app is that it is easy and quick to install, and it begins logging
Expand Down
2 changes: 1 addition & 1 deletion easyaudit/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
import models
from . import models

# Register your models here.
class CRUDEventAdmin(admin.ModelAdmin):
Expand Down
14 changes: 7 additions & 7 deletions easyaudit/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# django-easy-audit classes
from models import CRUDEvent, LoginEvent
from .models import CRUDEvent, LoginEvent

# django unregistered classes
from django.db.migrations import Migration
Expand All @@ -20,7 +20,7 @@
import datetime

# middleware
from middleware.easyaudit import EasyAuditMiddleware
from .middleware.easyaudit import EasyAuditMiddleware

# unregistered classes
UNREGISTERED_CLASSES = [CRUDEvent, LoginEvent, Migration, LogEntry, Session, Permission, ContentType]
Expand All @@ -44,7 +44,7 @@ def post_save(sender, instance, created, raw, using, update_fields, **kwargs):
# usuario
try:
user = EasyAuditMiddleware.request.user
except Exception, e:
except:
user = None

if isinstance(user, AnonymousUser):
Expand All @@ -62,7 +62,7 @@ def post_save(sender, instance, created, raw, using, update_fields, **kwargs):
)

crud_event.save()
except Exception, e:
except:
pass

def post_delete(sender, instance, using, **kwargs):
Expand Down Expand Up @@ -98,21 +98,21 @@ def user_logged_in(sender, request, user, **kwargs):
try:
login_event = LoginEvent(login_type=LoginEvent.LOGIN, username=user.username, user=user)
login_event.save()
except Exception, e:
except:
pass

def user_logged_out(sender, request, user, **kwargs):
try:
login_event = LoginEvent(login_type=LoginEvent.LOGOUT, username=user.username, user=user)
login_event.save()
except Exception, e:
except:
pass

def user_login_failed(sender, credentials, **kwargs):
try:
login_event = LoginEvent(login_type=LoginEvent.FAILED, username=credentials['username'])
login_event.save()
except Exception, e:
except:
pass

models_signals.post_save.connect(post_save)
Expand Down

0 comments on commit f366bf6

Please sign in to comment.