Merge pull request #133 from cloudbuilders/user_list
user listing improvements
This commit is contained in:
@@ -59,7 +59,7 @@ class AddUser(forms.SelfHandlingForm):
|
|||||||
except api_exceptions.ApiException, e:
|
except api_exceptions.ApiException, e:
|
||||||
messages.error(request, 'Unable to create user association: %s' %
|
messages.error(request, 'Unable to create user association: %s' %
|
||||||
(e.message))
|
(e.message))
|
||||||
return redirect('syspanel_tenants')
|
return redirect('syspanel_tenant_users', tenant_id=data['tenant'])
|
||||||
|
|
||||||
|
|
||||||
class RemoveUser(forms.SelfHandlingForm):
|
class RemoveUser(forms.SelfHandlingForm):
|
||||||
@@ -79,7 +79,7 @@ class RemoveUser(forms.SelfHandlingForm):
|
|||||||
except api_exceptions.ApiException, e:
|
except api_exceptions.ApiException, e:
|
||||||
messages.error(request, 'Unable to create tenant: %s' %
|
messages.error(request, 'Unable to create tenant: %s' %
|
||||||
(e.message))
|
(e.message))
|
||||||
return redirect('syspanel_tenants')
|
return redirect('syspanel_tenant_users', tenant_id=data['tenant'])
|
||||||
|
|
||||||
|
|
||||||
class CreateTenant(forms.SelfHandlingForm):
|
class CreateTenant(forms.SelfHandlingForm):
|
||||||
@@ -243,22 +243,15 @@ def users(request, tenant_id):
|
|||||||
|
|
||||||
users = api.account_api(request).users.get_for_tenant(tenant_id)
|
users = api.account_api(request).users.get_for_tenant(tenant_id)
|
||||||
all_users = api.account_api(request).users.list()
|
all_users = api.account_api(request).users.list()
|
||||||
new_user_ids = []
|
|
||||||
user_ids = [u.id for u in users]
|
user_ids = [u.id for u in users]
|
||||||
all_user_ids = [u.id for u in all_users]
|
new_users = [u for u in all_users if not u.id in user_ids]
|
||||||
for uid in all_user_ids:
|
|
||||||
if not uid in user_ids:
|
|
||||||
new_user_ids.append(uid)
|
|
||||||
for i in user_ids:
|
|
||||||
if i in new_user_ids:
|
|
||||||
new_user_ids.remove(i)
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
'django_openstack/syspanel/tenants/users.html', {
|
'django_openstack/syspanel/tenants/users.html', {
|
||||||
'add_user_form': add_user_form,
|
'add_user_form': add_user_form,
|
||||||
'remove_user_form': remove_user_form,
|
'remove_user_form': remove_user_form,
|
||||||
'tenant_id': tenant_id,
|
'tenant_id': tenant_id,
|
||||||
'users': users,
|
'users': users,
|
||||||
'new_users': new_user_ids,
|
'new_users': new_users,
|
||||||
}, context_instance=template.RequestContext(request))
|
}, context_instance=template.RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
{% for hidden in form.hidden_fields %}
|
{% for hidden in form.hidden_fields %}
|
||||||
{{hidden}}
|
{{hidden}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<input name="user" type="hidden" value="{{user}}" />
|
<input name="user" type="hidden" value="{{user.id}}" />
|
||||||
<input name="tenant" type="hidden" value="{{tenant_id}}" />
|
<input name="tenant" type="hidden" value="{{tenant_id}}" />
|
||||||
<input id="add_tenant_user_{{user}}" class="add" ttle="User: {{user}}" type="submit" value="Add" />
|
<input id="add_tenant_user_{{user.id}}" class="add" title="User: {{user.id}}" type="submit" value="Add" />
|
||||||
</form>
|
</form>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
{% if users %}
|
{% if users %}
|
||||||
<table class="wide">
|
<table class="wide">
|
||||||
<tr id='headings'>
|
<tr id='headings'>
|
||||||
|
<th>ID</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr class="{% cycle 'odd' 'even' %}">
|
<tr class="{% cycle 'odd' 'even' %}">
|
||||||
<td>{{user.id}}</td>
|
<td>{{user.id}}</td>
|
||||||
|
<td>{{user.name}}</td>
|
||||||
<td>{{user.email}}</td>
|
<td>{{user.email}}</td>
|
||||||
<td id="actions">
|
<td id="actions">
|
||||||
<ul>
|
<ul>
|
||||||
@@ -46,13 +48,15 @@
|
|||||||
<h3>Add new users</h3>
|
<h3>Add new users</h3>
|
||||||
<table class="wide">
|
<table class="wide">
|
||||||
<tr id='headings'>
|
<tr id='headings'>
|
||||||
|
<th>ID</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody class='main'>
|
<tbody class='main'>
|
||||||
{% for user in new_users %}
|
{% for user in new_users %}
|
||||||
<tr class="{% cycle 'odd' 'even' %}">
|
<tr class="{% cycle 'odd' 'even' %}">
|
||||||
<td>{{user}}</td>
|
<td>{{user.id}}</td>
|
||||||
|
<td>{{user.name}}</td>
|
||||||
<td id="actions">
|
<td id="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="form">{% include "django_openstack/syspanel/tenants/_add_user.html" with form=add_user_form %}</li>
|
<li class="form">{% include "django_openstack/syspanel/tenants/_add_user.html" with form=add_user_form %}</li>
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
<table class="wide">
|
<table class="wide">
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Default Tenant</th>
|
<th>Default Tenant</th>
|
||||||
<th>Options</th>
|
<th>Options</th>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr class="{% cycle 'odd' 'even' %}">
|
<tr class="{% cycle 'odd' 'even' %}">
|
||||||
<td>{{user.id}}{% if not user.enabled %} (disabled){% endif %}</td>
|
<td>{{user.id}}{% if not user.enabled %} (disabled){% endif %}</td>
|
||||||
|
<td>{{user.name}}</td>
|
||||||
<td>{{user.email}}</td>
|
<td>{{user.email}}</td>
|
||||||
<td>{{user.tenantId}}</td>
|
<td>{{user.tenantId}}</td>
|
||||||
<td id="actions">
|
<td id="actions">
|
||||||
|
Reference in New Issue
Block a user