mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 03:43:12 +00:00
Modifie la gestion des droits, depuis le profil maintenant
This commit is contained in:
parent
a0a2d5a6b5
commit
1c49c17801
5 changed files with 25 additions and 8 deletions
|
@ -131,12 +131,11 @@ class SchoolForm(ModelForm):
|
||||||
class RightForm(ModelForm):
|
class RightForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RightForm, self).__init__(*args, **kwargs)
|
super(RightForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['user'].label = 'Utilisateur'
|
|
||||||
self.fields['right'].label = 'Droit'
|
self.fields['right'].label = 'Droit'
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Right
|
model = Right
|
||||||
fields = ['user', 'right']
|
fields = ['right']
|
||||||
|
|
||||||
class DelRightForm(ModelForm):
|
class DelRightForm(ModelForm):
|
||||||
rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), label="Droits actuels", widget=forms.CheckboxSelectMultiple)
|
rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), label="Droits actuels", widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' user.id %}"><i class="glyphicon glyphicon-fire"></i> Editer</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' user.id %}"><i class="glyphicon glyphicon-fire"></i> Editer</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' user.id %}"><i class="glyphicon glyphicon-lock"></i> Changer le mot de passe</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' user.id %}"><i class="glyphicon glyphicon-lock"></i> Changer le mot de passe</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:state' user.id %}"><i class="glyphicon glyphicon-flash"></i> Changer le statut</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:state' user.id %}"><i class="glyphicon glyphicon-flash"></i> Changer le statut</a>
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-right' user.id %}"><i class="glyphicon glyphicon-ok"></i> Ajouter un droit</a>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -71,6 +72,12 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><font color="red">Désactivée</font></td>
|
<td><font color="red">Désactivée</font></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<th>Droits</th>
|
||||||
|
{% if list_droits %}
|
||||||
|
<td>{% for droit in list_droits %}{{ droit.right }} - {% endfor %}</td>
|
||||||
|
{% else %}
|
||||||
|
<td>Aucun</td>
|
||||||
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
<h2>Machines :</h2>
|
<h2>Machines :</h2>
|
||||||
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' user.id %}"><i class="glyphicon glyphicon-phone"></i> Ajouter une machine</a></h4>
|
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' user.id %}"><i class="glyphicon glyphicon-phone"></i> Ajouter une machine</a></h4>
|
||||||
|
|
|
@ -6,6 +6,5 @@
|
||||||
<p><a href="{% url "users:index" %}">Liste des adhérents</a></p>
|
<p><a href="{% url "users:index" %}">Liste des adhérents</a></p>
|
||||||
<p><a href="{% url "search:search" %}">Ajouter un bannissement</a></p>
|
<p><a href="{% url "search:search" %}">Ajouter un bannissement</a></p>
|
||||||
<p><a href="{% url "search:search" %}">Gérer les bannissements</a></p>
|
<p><a href="{% url "search:search" %}">Gérer les bannissements</a></p>
|
||||||
<p><a href="{% url "users:add-right" %}">Ajouter un droit rezo</a></p>
|
|
||||||
<p><a href="{% url "users:del-right" %}">Retirer un droit rezo</a></p>
|
<p><a href="{% url "users:del-right" %}">Retirer un droit rezo</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -11,7 +11,7 @@ urlpatterns = [
|
||||||
url(r'^edit_ban/(?P<banid>[0-9]+)$', views.edit_ban, name='edit-ban'),
|
url(r'^edit_ban/(?P<banid>[0-9]+)$', views.edit_ban, name='edit-ban'),
|
||||||
url(r'^add_whitelist/(?P<userid>[0-9]+)$', views.add_whitelist, name='add-whitelist'),
|
url(r'^add_whitelist/(?P<userid>[0-9]+)$', views.add_whitelist, name='add-whitelist'),
|
||||||
url(r'^edit_whitelist/(?P<whitelistid>[0-9]+)$', views.edit_whitelist, name='edit-whitelist'),
|
url(r'^edit_whitelist/(?P<whitelistid>[0-9]+)$', views.edit_whitelist, name='edit-whitelist'),
|
||||||
url(r'^add_right/$', views.add_right, name='add-right'),
|
url(r'^add_right/(?P<userid>[0-9]+)$', views.add_right, name='add-right'),
|
||||||
url(r'^del_right/$', views.del_right, name='del-right'),
|
url(r'^del_right/$', views.del_right, name='del-right'),
|
||||||
url(r'^profil/$', views.profil, name='profil'),
|
url(r'^profil/$', views.profil, name='profil'),
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.index, name='index'),
|
||||||
|
|
|
@ -7,6 +7,7 @@ from django.core.context_processors import csrf
|
||||||
from django.template import Context, RequestContext, loader
|
from django.template import Context, RequestContext, loader
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
from django.db import IntegrityError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm, ProfilForm, Whitelist, WhitelistForm
|
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm, ProfilForm, Whitelist, WhitelistForm
|
||||||
|
@ -128,11 +129,21 @@ def password(request, userid):
|
||||||
return redirect("/users/")
|
return redirect("/users/")
|
||||||
return form({'userform': user_form}, 'users/user.html', request)
|
return form({'userform': user_form}, 'users/user.html', request)
|
||||||
|
|
||||||
def add_right(request):
|
def add_right(request, userid):
|
||||||
|
try:
|
||||||
|
user = User.objects.get(pk=userid)
|
||||||
|
except User.DoesNotExist:
|
||||||
|
messages.error(request, u"Utilisateur inexistant" )
|
||||||
|
return redirect("/users/")
|
||||||
right = RightForm(request.POST or None)
|
right = RightForm(request.POST or None)
|
||||||
if right.is_valid():
|
if right.is_valid():
|
||||||
right.save()
|
right = right.save(commit=False)
|
||||||
messages.success(request, "Droit ajouté")
|
right.user = user
|
||||||
|
try:
|
||||||
|
right.save()
|
||||||
|
messages.success(request, "Droit ajouté")
|
||||||
|
except IntegrityError:
|
||||||
|
pass
|
||||||
return redirect("/users/")
|
return redirect("/users/")
|
||||||
return form({'userform': right}, 'users/user.html', request)
|
return form({'userform': right}, 'users/user.html', request)
|
||||||
|
|
||||||
|
@ -226,7 +237,8 @@ def profil(request):
|
||||||
end_bans=end_ban(users)
|
end_bans=end_ban(users)
|
||||||
if(is_whitelisted(users)):
|
if(is_whitelisted(users)):
|
||||||
end_whitelists=end_whitelist(users)
|
end_whitelists=end_whitelist(users)
|
||||||
return render(request, 'users/profil.html', {'user': users, 'machine_list' :machines, 'facture_list':factures, 'ban_list':bans, 'white_list':whitelists,'end_ban':end_bans,'end_whitelist':end_whitelists, 'end_adhesion':end_adhesion(users), 'actif':has_access(users)})
|
list_droits = Right.objects.filter(user=users)
|
||||||
|
return render(request, 'users/profil.html', {'user': users, 'machine_list' :machines, 'facture_list':factures, 'ban_list':bans, 'white_list':whitelists,'end_ban':end_bans,'end_whitelist':end_whitelists, 'end_adhesion':end_adhesion(users), 'actif':has_access(users), 'list_droits': list_droits})
|
||||||
return redirect("/users/")
|
return redirect("/users/")
|
||||||
return redirect("/users/")
|
return redirect("/users/")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue