Skip to content

Commit

Permalink
Switched API call to get single user from email address to user id
Browse files Browse the repository at this point in the history
  • Loading branch information
sebtesobe committed Jun 19, 2017
1 parent 4d02a6a commit b340764
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apimanager/users/templates/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2>Statistics</h2>
</thead>
<tbody>
{% for user in users %}
{% url 'users-detail' user.email as url_users_detail %}
{% url 'users-detail' user.user_id as url_users_detail %}
<tr data-user-id="{{ user.user_id }}">
<td><a href="{{ url_users_detail }}">{{ user.user_id }}</td>
<td>{{ user.username }}</td>
Expand Down
2 changes: 1 addition & 1 deletion apimanager/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
url(r'^$',
IndexView.as_view(),
name='users-index'),
url(r'^(?P<user_email>[\w\@\.\+-]+)$',
url(r'^user_id/(?P<user_id>[\w\@\.\+-]+)$',
DetailView.as_view(),
name='users-detail'),
url(r'^(?P<user_id>[\w-]+)/entitlement/delete/(?P<entitlement_id>[\w-]+)$',
Expand Down
8 changes: 3 additions & 5 deletions apimanager/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ def get_context_data(self, **kwargs):
# The API needs a call 'get user by id'!
user = {}
try:
urlpath = '/users/{}'.format(self.kwargs['user_email'])
users = api.get(self.request, urlpath)
if len(users['users']) > 0:
user = users['users'][0]
context['form'].fields['user_id'].initial = user['user_id']
urlpath = '/users/user_id/{}'.format(self.kwargs['user_id'])
user = api.get(self.request, urlpath)
context['form'].fields['user_id'].initial = user['user_id']
except APIError as err:
messages.error(self.request, err)

Expand Down

0 comments on commit b340764

Please sign in to comment.