mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-04 17:06:27 +00:00
Cree la view de creation d'un user
This commit is contained in:
parent
c405e8c078
commit
8c1383377a
5 changed files with 39 additions and 4 deletions
|
@ -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)
|
||||
|
|
5
users/templates/users/new_user.html
Normal file
5
users/templates/users/new_user.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<form class="form-full-width" method="post">{% csrf_token %}
|
||||
{% csrf_token %}
|
||||
{{ userform.as_p }}
|
||||
<input type="submit" value="Créer" />
|
||||
</form>
|
8
users/urls.py
Normal file
8
users/urls.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^new_user/$', views.new_user, name='new_user'),
|
||||
]
|
||||
|
|
@ -1,3 +1,24 @@
|
|||
# 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)
|
||||
|
|
Loading…
Reference in a new issue