8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 03:13:12 +00:00

Corrige des bugs , change le type de etat à integer, permet la creation d'un user de manière complète

This commit is contained in:
chirac 2016-07-01 01:03:28 +02:00
parent 8c1383377a
commit 28f324c642
3 changed files with 22 additions and 7 deletions

View file

@ -1,3 +1,12 @@
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)

View file

@ -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

View file

@ -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()
else:
user = UserForm()
return form({'userform': user}, 'users/new_user.html', request)
else:
user = InfoForm()
return form({'userform': user}, 'users/new_user.html', request)