mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Vue pour ajout et edition des banissements
This commit is contained in:
parent
dde4d6a112
commit
23eb878baf
2 changed files with 30 additions and 1 deletions
|
@ -7,6 +7,8 @@ urlpatterns = [
|
|||
url(r'^edit_info/(?P<userid>[0-9]+)$', views.edit_info, name='edit-info'),
|
||||
url(r'^state/(?P<userid>[0-9]+)$', views.state, name='state'),
|
||||
url(r'^password/(?P<userid>[0-9]+)$', views.password, name='password'),
|
||||
url(r'^add_ban/(?P<userid>[0-9]+)$', views.add_ban, name='add-ban'),
|
||||
url(r'^edit_ban/(?P<banid>[0-9]+)$', views.edit_ban, name='edit-ban'),
|
||||
url(r'^add_right/$', views.add_right, name='add-right'),
|
||||
url(r'^del_right/$', views.del_right, name='del-right'),
|
||||
url(r'^$', views.index, name='index'),
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.core.context_processors import csrf
|
|||
from django.template import Context, RequestContext, loader
|
||||
from django.contrib import messages
|
||||
|
||||
from users.models import User, Right, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm
|
||||
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm
|
||||
from users.forms import PassForm
|
||||
|
||||
from re2o.login import makeSecret, hashNT
|
||||
|
@ -86,6 +86,33 @@ def del_right(request):
|
|||
return redirect("/users/")
|
||||
return form({'userform': right}, 'users/user.html', request)
|
||||
|
||||
def add_ban(request, userid):
|
||||
try:
|
||||
user = User.objects.get(pk=userid)
|
||||
except User.DoesNotExist:
|
||||
messages.error(request, u"Utilisateur inexistant" )
|
||||
return redirect("/users/")
|
||||
ban_instance = Ban(user=user)
|
||||
ban = BanForm(request.POST or None, instance=ban_instance)
|
||||
if ban.is_valid():
|
||||
ban.save()
|
||||
messages.success(request, "Bannissement ajouté")
|
||||
return redirect("/users/")
|
||||
return form({'userform': ban}, 'users/user.html', request)
|
||||
|
||||
def edit_ban(request, banid):
|
||||
try:
|
||||
ban_instance = Ban.objects.get(pk=banid)
|
||||
except User.DoesNotExist:
|
||||
messages.error(request, u"Entrée inexistante" )
|
||||
return redirect("/users/")
|
||||
ban = BanForm(request.POST or None, instance=ban_instance)
|
||||
if ban.is_valid():
|
||||
ban.save()
|
||||
messages.success(request, "Bannissement modifié")
|
||||
return redirect("/users/")
|
||||
return form({'userform': ban}, 'users/user.html', request)
|
||||
|
||||
def index(request):
|
||||
users_list = User.objects.order_by('pk')
|
||||
return render(request, 'users/index.html', {'users_list': users_list})
|
||||
|
|
Loading…
Reference in a new issue