#81: Use AJAX code for participant status and superuser links in overview
This commit is contained in:
parent
ebbacfd443
commit
beb8694cdc
@ -1,6 +1,13 @@
|
|||||||
{% extends "participant/base_participant.html" %}
|
{% extends "participant/base_participant.html" %}
|
||||||
{% block title %}{{ block.super }} - {%trans "Participants" %}{% endblock %}
|
{% block title %}{{ block.super }} - {%trans "Participants" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block header %}
|
||||||
|
{% if perms.agenda.can_manage_agenda %}
|
||||||
|
<link type="text/css" rel="stylesheet" media="all" href="/static/styles/participant.css" />
|
||||||
|
<script type="text/javascript" src="/static/javascript/participant.js"></script>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% trans "Participants" %}</h1>
|
<h1>{% trans "Participants" %}</h1>
|
||||||
|
|
||||||
@ -73,16 +80,16 @@
|
|||||||
<td><span style="width: 1px; white-space: nowrap;">
|
<td><span style="width: 1px; white-space: nowrap;">
|
||||||
<a href="{% url user_edit user.id %}"><img src="/static/images/icons/document-edit.png" title="{%trans 'Edit participant' %}"></a>
|
<a href="{% url user_edit user.id %}"><img src="/static/images/icons/document-edit.png" title="{%trans 'Edit participant' %}"></a>
|
||||||
<a href="{% url user_delete user.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete participant' %}"></a>
|
<a href="{% url user_delete user.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete participant' %}"></a>
|
||||||
{% if user.is_active %}
|
<a class="status_link {% if user.is_active %}active{% else %}inactive{% endif %}"
|
||||||
<a href="{% url user_set_active user.id %}"><img src="/static/images/icons/user-online.png" title="{%trans 'Participiant is activated. Click to deactivate!' %}"></a>
|
href="{% if user.is_active %}{% url user_inactive user.id %}{% else %}{% url user_active user.id %}{% endif %}"
|
||||||
{% else %}
|
title="{%trans 'Change status (active/inactive)' %}">
|
||||||
<a href="{% url user_set_active user.id %}"><img src="/static/images/icons/user-offline.png" title="{%trans 'Participiant is deactivated. Click to activate!' %}"></a>
|
<span></span>
|
||||||
{% endif %}
|
</a>
|
||||||
{% if user.is_superuser %}
|
<a class="superuser_link {% if user.is_superuser %}superuser{% else %}normaluser{% endif %}"
|
||||||
<a href="{% url user_set_superuser user.id %}"><img src="/static/images/icons/meeting-chair.png" title="{%trans 'Administrator. Click to get normal user!' %}"></a>
|
href="{% if user.is_superuser %}{% url user_normaluser user.id %}{% else %}{% url user_superuser user.id %}{% endif %}"
|
||||||
{% else %}
|
title="{%trans 'Change administrator rights (Superuser/Normal user)' %}">
|
||||||
<a href="{% url user_set_superuser user.id %}"><img src="/static/images/icons/im-user.png" title="{%trans 'Normal user. Click to get administrator!' %}"></a>
|
<span></span>
|
||||||
{% endif %}
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -19,8 +19,11 @@ urlpatterns = patterns('participant.views',
|
|||||||
url(r'^participant/(?P<user_id>\d+)/edit$', 'edit', name='user_edit'),
|
url(r'^participant/(?P<user_id>\d+)/edit$', 'edit', name='user_edit'),
|
||||||
url(r'^participant/print$', 'print_userlist', name='user_print'),
|
url(r'^participant/print$', 'print_userlist', name='user_print'),
|
||||||
url(r'^participant/(?P<user_id>\d+)/del$', 'user_delete', name='user_delete'),
|
url(r'^participant/(?P<user_id>\d+)/del$', 'user_delete', name='user_delete'),
|
||||||
url(r'^participant/(?P<user_id>\d+)/admin$', 'user_set_superuser', name='user_set_superuser'),
|
url(r'^participant/(?P<user_id>\d+)/active/$', 'user_set_active', {'active': True}, name='user_active'),
|
||||||
url(r'^participant/(?P<user_id>\d+)/active$', 'user_set_active', name='user_set_active'),
|
url(r'^participant/(?P<user_id>\d+)/inactive/$', 'user_set_active', {'active': False}, name='user_inactive'),
|
||||||
|
url(r'^participant/(?P<user_id>\d+)/superuser/$', 'user_set_superuser', {'superuser': True}, name='user_superuser'),
|
||||||
|
url(r'^participant/(?P<user_id>\d+)/normaluser/$', 'user_set_superuser', {'superuser': False}, name='user_normaluser'),
|
||||||
|
|
||||||
url(r'^participant/import$', 'user_import', name='user_import'),
|
url(r'^participant/import$', 'user_import', name='user_import'),
|
||||||
url(r'^participant/group/$', 'get_group_overview', name='user_group_overview'),
|
url(r'^participant/group/$', 'get_group_overview', name='user_group_overview'),
|
||||||
url(r'^participant/group/new$', 'group_edit', name='user_group_new'),
|
url(r'^participant/group/new$', 'group_edit', name='user_group_new'),
|
||||||
|
@ -34,7 +34,7 @@ from django.db import transaction
|
|||||||
from participant.models import Profile
|
from participant.models import Profile
|
||||||
from participant.api import gen_username, gen_password
|
from participant.api import gen_username, gen_password
|
||||||
from participant.forms import UserNewForm, UserEditForm, ProfileForm, UsersettingsForm, UserImportForm, GroupForm, AdminPasswordChangeForm
|
from participant.forms import UserNewForm, UserEditForm, ProfileForm, UsersettingsForm, UserImportForm, GroupForm, AdminPasswordChangeForm
|
||||||
from utils.utils import template, permission_required, gen_confirm_form
|
from utils.utils import template, permission_required, gen_confirm_form, ajax_request
|
||||||
from utils.pdf import print_userlist, print_passwords
|
from utils.pdf import print_userlist, print_passwords
|
||||||
from system.api import config_get
|
from system.api import config_get
|
||||||
|
|
||||||
@ -176,30 +176,40 @@ def user_delete(request, user_id):
|
|||||||
|
|
||||||
@permission_required('participant.can_manage_participant')
|
@permission_required('participant.can_manage_participant')
|
||||||
@template('confirm.html')
|
@template('confirm.html')
|
||||||
def user_set_superuser(request, user_id):
|
def user_set_superuser(request, user_id, superuser=True):
|
||||||
user = User.objects.get(pk=user_id)
|
try:
|
||||||
if user.is_superuser:
|
user = User.objects.get(pk=user_id)
|
||||||
user.is_superuser = False
|
user.is_superuser = superuser
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, _('Participant <b>%s</b> is now a normal user.') % user)
|
except User.DoesNotExist:
|
||||||
else:
|
messages.error(request, _('Participant %d does not exist.') % int(user_id))
|
||||||
user.is_superuser = True
|
|
||||||
user.save()
|
if request.is_ajax():
|
||||||
messages.success(request, _('Participant <b>%s</b> is now administrator.') % user)
|
if superuser:
|
||||||
|
link = reverse('user_normaluser', args=[user.id])
|
||||||
|
else:
|
||||||
|
link = reverse('user_superuser', args=[user.id])
|
||||||
|
return ajax_request({'superuser': superuser,
|
||||||
|
'link': link})
|
||||||
return redirect(reverse('user_overview'))
|
return redirect(reverse('user_overview'))
|
||||||
|
|
||||||
@permission_required('participant.can_manage_participant')
|
@permission_required('participant.can_manage_participant')
|
||||||
@template('confirm.html')
|
@template('confirm.html')
|
||||||
def user_set_active(request, user_id):
|
def user_set_active(request, user_id, active=True):
|
||||||
user = User.objects.get(pk=user_id)
|
try:
|
||||||
if user.is_active:
|
user = User.objects.get(pk=user_id)
|
||||||
user.is_active = False
|
user.is_active = active
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, _('Participant <b>%s</b> was successfully deactivated.') % user)
|
except User.DoesNotExist:
|
||||||
else:
|
messages.error(request, _('Participant %d does not exist.') % int(user_id))
|
||||||
user.is_active = True
|
|
||||||
user.save()
|
if request.is_ajax():
|
||||||
messages.success(request, _('Participant <b>%s</b> was successfully activated.') % user)
|
if active:
|
||||||
|
link = reverse('user_inactive', args=[user.id])
|
||||||
|
else:
|
||||||
|
link = reverse('user_active', args=[user.id])
|
||||||
|
return ajax_request({'active': active,
|
||||||
|
'link': link})
|
||||||
return redirect(reverse('user_overview'))
|
return redirect(reverse('user_overview'))
|
||||||
|
|
||||||
@permission_required('participant.can_manage_participant')
|
@permission_required('participant.can_manage_participant')
|
||||||
|
39
openslides/static/javascript/participant.js
Normal file
39
openslides/static/javascript/participant.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
$(function() {
|
||||||
|
$('.status_link').click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
link = $(this);
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: link.attr('href'),
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
if (data.active) {
|
||||||
|
newclass = 'active';
|
||||||
|
} else {
|
||||||
|
newclass = 'inactive';
|
||||||
|
}
|
||||||
|
link.removeClass('active inactive').addClass(newclass);
|
||||||
|
link.attr('href', data.link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.superuser_link').click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
link = $(this);
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: link.attr('href'),
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
if (data.superuser) {
|
||||||
|
newclass = 'superuser';
|
||||||
|
} else {
|
||||||
|
newclass = 'normaluser';
|
||||||
|
}
|
||||||
|
link.removeClass('superuser normaluser').addClass(newclass);
|
||||||
|
link.attr('href', data.link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
33
openslides/static/styles/participant.css
Normal file
33
openslides/static/styles/participant.css
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
a.status_link.active span {
|
||||||
|
background-image: url(/static/images/icons/user-online.png);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
a.status_link.inactive span {
|
||||||
|
background-image: url(/static/images/icons/user-offline.png);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.superuser_link.superuser span {
|
||||||
|
background-image: url(/static/images/icons/meeting-chair.png);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
a.superuser_link.normaluser span {
|
||||||
|
background-image: url(/static/images/icons/im-user.png);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user