8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 00:43:46 +00:00
re2o/users/views.py

26 lines
825 B
Python
Raw Normal View History

2016-06-30 18:18:06 +00:00
# App de gestion des users pour re2o
# Goulven Kermarec, Gabriel Détraz
# Gplv2
2016-06-30 01:39:07 +00:00
from django.shortcuts import render
2016-06-30 18:18:06 +00:00
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
2016-06-30 01:39:07 +00:00
from users.models import UserForm, InfoForm
2016-06-30 18:18:06 +00:00
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 = InfoForm(request.POST)
2016-06-30 18:18:06 +00:00
if user.is_valid():
user.save()
return form({'userform': user}, 'users/new_user.html', request)
2016-06-30 18:18:06 +00:00
else:
user = InfoForm()
2016-06-30 18:18:06 +00:00
return form({'userform': user}, 'users/new_user.html', request)