Commit 28f324c6 authored by chirac's avatar chirac

Corrige des bugs , change le type de etat à integer, permet la creation d'un...

Corrige des bugs , change le type de etat à integer, permet la creation d'un user de manière complète
parent 8c138337
from django.contrib import admin
# Register your models here.
from .models import User, School
class UserAdmin(admin.ModelAdmin):
list_display = ('name','surname','pseudo','email', 'school', 'state')
class SchoolAdmin(admin.ModelAdmin):
list_display = ('name',)
admin.site.register(User, UserAdmin)
admin.site.register(School, SchoolAdmin)
......@@ -13,19 +13,24 @@ class User(models.Model):
name = models.CharField(max_length=255)
surname = models.CharField(max_length=255)
pseudo = models.CharField(max_length=255)
pseudo = models.CharField(max_length=255, unique=True)
email = models.EmailField()
school = models.ForeignKey('School', on_delete=models.PROTECT)
promo = models.CharField(max_length=255)
pwd_ssha = models.CharField(max_length=255)
pwd_ntlm = models.CharField(max_length=255)
#location = models.ForeignKey('Location', on_delete=models.SET_DEFAULT)
state = models.CharField(max_length=30, choices=STATES, default=STATE_ACTIVE)
state = models.IntegerField(choices=STATES, default=STATE_ACTIVE)
def __str__(self):
return self.name
class School(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class UserForm(ModelForm):
class Meta:
model = User
......
......@@ -6,7 +6,7 @@ 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 users.models import UserForm
from users.models import UserForm, InfoForm
def form(ctx, template, request):
......@@ -16,9 +16,10 @@ def form(ctx, template, request):
def new_user(request):
if request.method == 'POST':
user = UserForm(request.Post)
user = InfoForm(request.POST)
if user.is_valid():
user.save()
return form({'userform': user}, 'users/new_user.html', request)
else:
user = UserForm()
user = InfoForm()
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