#81: Merged fix of r363 from default branch into 1.2-dev branch.

This commit is contained in:
Emanuel Schuetze 2012-04-02 08:35:10 +02:00
parent 4045c79a17
commit 9c13667ff0
5 changed files with 123 additions and 31 deletions

View File

@ -4,6 +4,13 @@
{% 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>
@ -76,16 +83,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 %}

View File

@ -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'),

View File

@ -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 utils.template import Tab from utils.template import Tab
from system import config from system import config
@ -177,30 +177,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):
try:
user = User.objects.get(pk=user_id) user = User.objects.get(pk=user_id)
if user.is_superuser: user.is_superuser = superuser
user.is_superuser = False
user.save() user.save()
messages.success(request, _('Participant <b>%s</b> is now a normal user.') % 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: else:
user.is_superuser = True link = reverse('user_superuser', args=[user.id])
user.save() return ajax_request({'superuser': superuser,
messages.success(request, _('Participant <b>%s</b> is now administrator.') % user) '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):
try:
user = User.objects.get(pk=user_id) user = User.objects.get(pk=user_id)
if user.is_active: user.is_active = active
user.is_active = False
user.save() user.save()
messages.success(request, _('Participant <b>%s</b> was successfully deactivated.') % 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: else:
user.is_active = True link = reverse('user_active', args=[user.id])
user.save() return ajax_request({'active': active,
messages.success(request, _('Participant <b>%s</b> was successfully activated.') % user) 'link': link})
return redirect(reverse('user_overview')) return redirect(reverse('user_overview'))
@permission_required('participant.can_manage_participant') @permission_required('participant.can_manage_participant')

View 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);
}
});
});
});

View 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;
}