Commit 8c138337 authored by chirac's avatar chirac

Cree la view de creation d'un user

parent c405e8c0
......@@ -17,4 +17,5 @@ from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^users/', include('users.urls')),
]
......@@ -6,9 +6,9 @@ class User(models.Model):
STATE_DEACTIVATED = 1
STATE_ARCHIVED = 2
STATES = (
(0, 'STATE_ACTIVE')
(1, 'STATE_DEACTIVATED')
(2, 'STATE_ARCHIVED')
(0, 'STATE_ACTIVE'),
(1, 'STATE_DEACTIVATED'),
(2, 'STATE_ARCHIVED'),
)
name = models.CharField(max_length=255)
......
<form class="form-full-width" method="post">{% csrf_token %}
{% csrf_token %}
{{ userform.as_p }}
<input type="submit" value="Créer" />
</form>
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^new_user/$', views.new_user, name='new_user'),
]
# App de gestion des users pour re2o
# Goulven Kermarec, Gabriel Détraz
# Gplv2
from django.shortcuts import render
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
# Create your views here.
from users.models import UserForm
def form(ctx, template, request):
c = ctx
c.update(csrf(request))
return render_to_response(template, c, context_instance=RequestContext(request))
def new_user(request):
if request.method == 'POST':
user = UserForm(request.Post)
if user.is_valid():
user.save()
else:
user = UserForm()
return form({'userform': user}, 'users/new_user.html', request)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment