mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 00:13:45 +00:00
Ajoute un menu pour changer l'etat et le mot de passe
This commit is contained in:
parent
e31d0695df
commit
998289ce5a
4 changed files with 41 additions and 3 deletions
|
@ -18,4 +18,5 @@ from django.contrib import admin
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^users/', include('users.urls')),
|
url(r'^users/', include('users.urls')),
|
||||||
|
url(r'^search/', include('search.urls')),
|
||||||
]
|
]
|
||||||
|
|
8
users/forms.py
Normal file
8
users/forms.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
|
||||||
|
class PassForm(forms.Form):
|
||||||
|
passwd = forms.CharField(label=u'Nouveau mot de passe', max_length=255, widget=forms.PasswordInput)
|
|
@ -5,5 +5,8 @@ from . import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^new_user/$', views.new_user, name='new_user'),
|
url(r'^new_user/$', views.new_user, name='new_user'),
|
||||||
url(r'^edit_info/(?P<userid>[0-9]+)$', views.edit_info, name='edit_info'),
|
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'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
# App de gestion des users pour re2o
|
# App de gestion des users pour re2o
|
||||||
# Goulven Kermarec, Gabriel Détraz
|
# Goulven Kermarec, Gabriel Détraz
|
||||||
# Gplv2
|
# Gplv2
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
from django.shortcuts import render_to_response, get_object_or_404
|
from django.shortcuts import render_to_response, get_object_or_404
|
||||||
from django.core.context_processors import csrf
|
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 users.models import User, UserForm, InfoForm, PasswordForm, StateForm
|
from users.models import User, UserForm, InfoForm, PasswordForm, StateForm
|
||||||
|
from users.forms import PassForm
|
||||||
|
|
||||||
def form(ctx, template, request):
|
def form(ctx, template, request):
|
||||||
c = ctx
|
c = ctx
|
||||||
|
@ -28,8 +29,33 @@ def edit_info(request, userid):
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(pk=userid)
|
user = User.objects.get(pk=userid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
user = None
|
messages.error(request, u"Utilisateur inexistant" )
|
||||||
|
return redirect("/users/")
|
||||||
user = InfoForm(request.POST or None, instance=user)
|
user = InfoForm(request.POST or None, instance=user)
|
||||||
if user.is_valid():
|
if user.is_valid():
|
||||||
user.save()
|
user.save()
|
||||||
return form({'userform': user}, 'users/user.html', request)
|
return form({'userform': user}, 'users/user.html', request)
|
||||||
|
|
||||||
|
def state(request, userid):
|
||||||
|
try:
|
||||||
|
user = User.objects.get(pk=userid)
|
||||||
|
except User.DoesNotExist:
|
||||||
|
messages.error(request, u"Utilisateur inexistant" )
|
||||||
|
return redirect("/users/")
|
||||||
|
user = StateForm(request.POST or None, instance=user)
|
||||||
|
if user.is_valid():
|
||||||
|
user.save()
|
||||||
|
return form({'userform': user}, 'users/user.html', request)
|
||||||
|
|
||||||
|
def password(request, userid):
|
||||||
|
try:
|
||||||
|
user = User.objects.get(pk=userid)
|
||||||
|
except User.DoesNotExist:
|
||||||
|
messages.error(request, u"Utilisateur inexistant" )
|
||||||
|
return redirect("/users/")
|
||||||
|
user_form = PassForm(request.POST or None)
|
||||||
|
if user_form.is_valid():
|
||||||
|
user.pwd_ssha = user_form.cleaned_data['passwd']
|
||||||
|
user.pwd_ntlm = user_form.cleaned_data['passwd']
|
||||||
|
user.save()
|
||||||
|
return form({'userform': user_form}, 'users/user.html', request)
|
||||||
|
|
Loading…
Reference in a new issue