diff --git a/passbook/admin/templates/administration/invitation/list.html b/passbook/admin/templates/administration/invitation/list.html index d3ab34faf..12b6bcda0 100644 --- a/passbook/admin/templates/administration/invitation/list.html +++ b/passbook/admin/templates/administration/invitation/list.html @@ -26,7 +26,7 @@ {% for invitation in object_list %} {{ invitation.expires|default:"Never" }} -
test
+
{{ invitation.link }}
{% trans 'Delete' %} diff --git a/passbook/audit/models.py b/passbook/audit/models.py index 18521b526..da9b4ab07 100644 --- a/passbook/audit/models.py +++ b/passbook/audit/models.py @@ -3,6 +3,7 @@ from json import dumps, loads from logging import getLogger from django.conf import settings +from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import gettext as _ @@ -57,9 +58,12 @@ class AuditEntry(UUIDModel): def create(action, request, **kwargs): """Create AuditEntry from arguments""" client_ip, _ = get_client_ip(request) + user = request.user + if isinstance(user, AnonymousUser): + user = kwargs.get('user', None) entry = AuditEntry.objects.create( action=action, - user=request.user, + user=user, # User 255.255.255.255 as fallback if IP cannot be determined request_ip=client_ip or '255.255.255.255', _context=dumps(kwargs)) diff --git a/passbook/audit/signals.py b/passbook/audit/signals.py index fa5f22777..8d9f67922 100644 --- a/passbook/audit/signals.py +++ b/passbook/audit/signals.py @@ -26,12 +26,14 @@ def on_user_signed_up(sender, request, user, **kwargs): @receiver(invitation_created) def on_invitation_created(sender, request, invitation, **kwargs): """Log Invitation creation""" - AuditEntry.create(AuditEntry.ACTION_INVITE_CREATED, request, invitation_uuid=invitation.uuid) + AuditEntry.create(AuditEntry.ACTION_INVITE_CREATED, request, + invitation_uuid=invitation.uuid.hex) @receiver(invitation_used) def on_invitation_used(sender, request, invitation, **kwargs): """Log Invitation usage""" - AuditEntry.create(AuditEntry.ACTION_INVITE_USED, request, invitation_uuid=invitation.uuid) + AuditEntry.create(AuditEntry.ACTION_INVITE_USED, request, + invitation_uuid=invitation.uuid.hex) @receiver(user_login_failed) def on_user_login_failed(sender, request, user, **kwargs):