mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Ajoute un menu pour changer l'etat et le mot de passe
This commit is contained in:
parent
b3872eb0c6
commit
5d81cbdd15
4 changed files with 41 additions and 3 deletions
|
@ -18,4 +18,5 @@ from django.contrib import admin
|
|||
urlpatterns = [
|
||||
url(r'^admin/', include(admin.site.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 = [
|
||||
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'^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
|
||||
# Goulven Kermarec, Gabriel Détraz
|
||||
# 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.core.context_processors import csrf
|
||||
from django.template import Context, RequestContext, loader
|
||||
from django.contrib import messages
|
||||
|
||||
from users.models import User, UserForm, InfoForm, PasswordForm, StateForm
|
||||
|
||||
from users.forms import PassForm
|
||||
|
||||
def form(ctx, template, request):
|
||||
c = ctx
|
||||
|
@ -28,8 +29,33 @@ def edit_info(request, userid):
|
|||
try:
|
||||
user = User.objects.get(pk=userid)
|
||||
except User.DoesNotExist:
|
||||
user = None
|
||||
messages.error(request, u"Utilisateur inexistant" )
|
||||
return redirect("/users/")
|
||||
user = InfoForm(request.POST or None, instance=user)
|
||||
if user.is_valid():
|
||||
user.save()
|
||||
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