#81: Merged fix of r363 from default branch into 1.2-dev branch.
This commit is contained in:
parent
4045c79a17
commit
9c13667ff0
@ -4,6 +4,13 @@
|
||||
|
||||
{% 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 %}
|
||||
<h1>{% trans "Participants" %}</h1>
|
||||
|
||||
@ -76,16 +83,16 @@
|
||||
<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_delete user.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete participant' %}"></a>
|
||||
{% if user.is_active %}
|
||||
<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>
|
||||
{% else %}
|
||||
<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>
|
||||
{% endif %}
|
||||
{% if user.is_superuser %}
|
||||
<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>
|
||||
{% else %}
|
||||
<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>
|
||||
{% endif %}
|
||||
<a class="status_link {% if user.is_active %}active{% else %}inactive{% endif %}"
|
||||
href="{% if user.is_active %}{% url user_inactive user.id %}{% else %}{% url user_active user.id %}{% endif %}"
|
||||
title="{%trans 'Change status (active/inactive)' %}">
|
||||
<span></span>
|
||||
</a>
|
||||
<a class="superuser_link {% if user.is_superuser %}superuser{% else %}normaluser{% endif %}"
|
||||
href="{% if user.is_superuser %}{% url user_normaluser user.id %}{% else %}{% url user_superuser user.id %}{% endif %}"
|
||||
title="{%trans 'Change administrator rights (Superuser/Normal user)' %}">
|
||||
<span></span>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
@ -19,8 +19,11 @@ urlpatterns = patterns('participant.views',
|
||||
url(r'^participant/(?P<user_id>\d+)/edit$', 'edit', name='user_edit'),
|
||||
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+)/admin$', 'user_set_superuser', name='user_set_superuser'),
|
||||
url(r'^participant/(?P<user_id>\d+)/active$', 'user_set_active', name='user_set_active'),
|
||||
url(r'^participant/(?P<user_id>\d+)/active/$', 'user_set_active', {'active': True}, name='user_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/group/$', 'get_group_overview', name='user_group_overview'),
|
||||
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.api import gen_username, gen_password
|
||||
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.template import Tab
|
||||
from system import config
|
||||
@ -177,30 +177,40 @@ def user_delete(request, user_id):
|
||||
|
||||
@permission_required('participant.can_manage_participant')
|
||||
@template('confirm.html')
|
||||
def user_set_superuser(request, user_id):
|
||||
user = User.objects.get(pk=user_id)
|
||||
if user.is_superuser:
|
||||
user.is_superuser = False
|
||||
def user_set_superuser(request, user_id, superuser=True):
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
user.is_superuser = superuser
|
||||
user.save()
|
||||
messages.success(request, _('Participant <b>%s</b> is now a normal user.') % user)
|
||||
else:
|
||||
user.is_superuser = True
|
||||
user.save()
|
||||
messages.success(request, _('Participant <b>%s</b> is now administrator.') % user)
|
||||
except User.DoesNotExist:
|
||||
messages.error(request, _('Participant %d does not exist.') % int(user_id))
|
||||
|
||||
if request.is_ajax():
|
||||
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'))
|
||||
|
||||
@permission_required('participant.can_manage_participant')
|
||||
@template('confirm.html')
|
||||
def user_set_active(request, user_id):
|
||||
user = User.objects.get(pk=user_id)
|
||||
if user.is_active:
|
||||
user.is_active = False
|
||||
def user_set_active(request, user_id, active=True):
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
user.is_active = active
|
||||
user.save()
|
||||
messages.success(request, _('Participant <b>%s</b> was successfully deactivated.') % user)
|
||||
else:
|
||||
user.is_active = True
|
||||
user.save()
|
||||
messages.success(request, _('Participant <b>%s</b> was successfully activated.') % user)
|
||||
except User.DoesNotExist:
|
||||
messages.error(request, _('Participant %d does not exist.') % int(user_id))
|
||||
|
||||
if request.is_ajax():
|
||||
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'))
|
||||
|
||||
@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