Use same url to toggle participant status.
This commit is contained in:
parent
3a52cd56c6
commit
189c975137
@ -15,12 +15,10 @@ $(function() {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.active) {
|
if (data.active) {
|
||||||
newclass = 'active';
|
link.addClass('active');
|
||||||
} else {
|
} else {
|
||||||
newclass = 'inactive';
|
link.removeClass('active');
|
||||||
}
|
}
|
||||||
link.removeClass('active inactive').addClass(newclass);
|
|
||||||
link.attr('href', data.link);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,16 +4,7 @@
|
|||||||
* :copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
|
* :copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
|
||||||
* :license: GNU GPL, see LICENSE for more details.
|
* :license: GNU GPL, see LICENSE for more details.
|
||||||
*/
|
*/
|
||||||
|
a.status_link span {
|
||||||
a.status_link.active span {
|
|
||||||
background-image: url(../images/icons/on.png);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
a.status_link.inactive span {
|
|
||||||
background-image: url(../images/icons/off.png);
|
background-image: url(../images/icons/off.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
@ -21,3 +12,6 @@ a.status_link.inactive span {
|
|||||||
height: 16px;
|
height: 16px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
a.status_link.active span {
|
||||||
|
background-image: url(../images/icons/on.png);
|
||||||
|
}
|
||||||
|
@ -87,8 +87,8 @@
|
|||||||
<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/edit.png' %}" title="{%trans 'Edit participant' %}"></a>
|
<a href="{% url user_edit user.id %}"><img src="{% static 'images/icons/edit.png' %}" title="{%trans 'Edit participant' %}"></a>
|
||||||
<a href="{% url user_delete user.id %}"><img src="{% static 'images/icons/delete.png' %}" title="{%trans 'Delete participant' %}"></a>
|
<a href="{% url user_delete user.id %}"><img src="{% static 'images/icons/delete.png' %}" title="{%trans 'Delete participant' %}"></a>
|
||||||
<a class="status_link {% if user.is_active %}active{% else %}inactive{% endif %}"
|
<a class="status_link {% if user.is_active %}active{% endif %}"
|
||||||
href="{% if user.is_active %}{% url user_inactive user.id %}{% else %}{% url user_active user.id %}{% endif %}"
|
href="{% url user_status user.id %}"
|
||||||
title="{%trans 'Change status (active/inactive)' %}">
|
title="{%trans 'Change status (active/inactive)' %}">
|
||||||
<span></span>
|
<span></span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -41,16 +41,9 @@ urlpatterns = patterns('participant.views',
|
|||||||
name='user_delete',
|
name='user_delete',
|
||||||
),
|
),
|
||||||
|
|
||||||
url(r'^(?P<user_id>\d+)/active/$',
|
url(r'^(?P<user_id>\d+)/status/$',
|
||||||
'user_set_active',
|
'user_set_status',
|
||||||
{'active': True},
|
name='user_status',
|
||||||
name='user_active',
|
|
||||||
),
|
|
||||||
|
|
||||||
url(r'^(?P<user_id>\d+)/inactive/$',
|
|
||||||
'user_set_active',
|
|
||||||
{'active': False},
|
|
||||||
name='user_inactive',
|
|
||||||
),
|
),
|
||||||
|
|
||||||
url(r'^import$',
|
url(r'^import$',
|
||||||
|
@ -198,21 +198,26 @@ 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_active(request, user_id, active=True):
|
def user_set_status(request, user_id):
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(pk=user_id)
|
user = User.objects.get(pk=user_id)
|
||||||
user.is_active = active
|
if user.is_active:
|
||||||
|
user.is_active = False
|
||||||
|
else:
|
||||||
|
user.is_active = True
|
||||||
user.save()
|
user.save()
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
messages.error(request, _('Participant %d does not exist.') % int(user_id))
|
messages.error(request, _('Participant ID %d does not exist.') % int(user_id))
|
||||||
|
return redirect(reverse('user_overview'))
|
||||||
|
|
||||||
if request.is_ajax():
|
if request.is_ajax():
|
||||||
if active:
|
link = reverse('user_status', args=[user.id])
|
||||||
link = reverse('user_inactive', args=[user.id])
|
return ajax_request({'active': user.is_active})
|
||||||
else:
|
# set success messages for page reload only (= not ajax request)
|
||||||
link = reverse('user_active', args=[user.id])
|
if user.is_active:
|
||||||
return ajax_request({'active': active,
|
messages.success(request, _('<b>%s</b> is now <b>present</b>.') % user)
|
||||||
'link': link})
|
else:
|
||||||
|
messages.success(request, _('<b>%s</b> is now <b>absent</b>.') % user)
|
||||||
return redirect(reverse('user_overview'))
|
return redirect(reverse('user_overview'))
|
||||||
|
|
||||||
@permission_required('participant.can_manage_participant')
|
@permission_required('participant.can_manage_participant')
|
||||||
|
Loading…
Reference in New Issue
Block a user