mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 08:32:26 +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:
parent
8c1383377a
commit
28f324c642
3 changed files with 22 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
||||||
from django.contrib import admin
|
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)
|
name = models.CharField(max_length=255)
|
||||||
surname = 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()
|
email = models.EmailField()
|
||||||
school = models.ForeignKey('School', on_delete=models.PROTECT)
|
school = models.ForeignKey('School', on_delete=models.PROTECT)
|
||||||
promo = models.CharField(max_length=255)
|
promo = models.CharField(max_length=255)
|
||||||
pwd_ssha = models.CharField(max_length=255)
|
pwd_ssha = models.CharField(max_length=255)
|
||||||
pwd_ntlm = models.CharField(max_length=255)
|
pwd_ntlm = models.CharField(max_length=255)
|
||||||
#location = models.ForeignKey('Location', on_delete=models.SET_DEFAULT)
|
#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):
|
class School(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
class UserForm(ModelForm):
|
class UserForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
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.core.context_processors import csrf
|
||||||
from django.template import Context, RequestContext, loader
|
from django.template import Context, RequestContext, loader
|
||||||
|
|
||||||
from users.models import UserForm
|
from users.models import UserForm, InfoForm
|
||||||
|
|
||||||
|
|
||||||
def form(ctx, template, request):
|
def form(ctx, template, request):
|
||||||
|
@ -16,9 +16,10 @@ def form(ctx, template, request):
|
||||||
|
|
||||||
def new_user(request):
|
def new_user(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
user = UserForm(request.Post)
|
user = InfoForm(request.POST)
|
||||||
if user.is_valid():
|
if user.is_valid():
|
||||||
user.save()
|
user.save()
|
||||||
else:
|
return form({'userform': user}, 'users/new_user.html', request)
|
||||||
user = UserForm()
|
else:
|
||||||
|
user = InfoForm()
|
||||||
return form({'userform': user}, 'users/new_user.html', request)
|
return form({'userform': user}, 'users/new_user.html', request)
|
||||||
|
|
Loading…
Reference in a new issue