Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the django default user method get_username() in the history for #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions binder/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Changeset(models.Model):

def __str__(self):
uuid = self.uuid[:8] if self.uuid else None
username = self.user.username if self.user else None
username = self.user.get_username() if self.user else None
return '{}/{} by {} on {}'.format(self.id, uuid, username, self.date.strftime('%Y%m%d-%H%M%S'))

class Meta:
Expand Down Expand Up @@ -215,7 +215,7 @@ def view_changesets(request, changesets):

users = []
for u in get_user_model().objects.filter(id__in=userids):
users.append({'id': u.id, 'username': u.username, 'email': u.email, 'first_name': u.first_name, 'last_name': u.last_name})
users.append({'id': u.id, 'username': u.get_username(), 'email': u.email, 'first_name': u.first_name, 'last_name': u.last_name})

return JsonResponse({'data': data, 'with': {'user': users}})

Expand All @@ -224,7 +224,7 @@ def view_changesets(request, changesets):
def view_changesets_debug(request, changesets):
body = ['<html>', '<head>', '<style type="text/css">td {padding: 0px 20px;} th {padding: 0px 20px;}</style>', '</head>', '<body>']
for cs in changesets:
username = cs.user.username if cs.user else None
username = cs.user.get_username() if cs.user else None
body.append('<h3>Changeset {} by {}: {} on {} {{{}}}'.format(cs.id, cs.source, username, cs.date.strftime('%Y-%m-%d %H:%M:%S'), cs.uuid))
body.append('<br><br>')
body.append('<table>')
Expand Down