Browse Source

Un adhérent par chambre et inversement (one to one)

rewrite_authors
Gabriel Detraz 10 years ago
parent
commit
4cdcb9d974
  1. BIN
      topologie/__pycache__/admin.cpython-34.pyc
  2. 2
      topologie/admin.py
  3. 2
      users/admin.py
  4. 10
      users/models.py

BIN
topologie/__pycache__/admin.cpython-34.pyc

Binary file not shown.

2
topologie/admin.py

@ -7,7 +7,7 @@ class SwitchAdmin(admin.ModelAdmin):
list_display = ('building','number','details')
class PortAdmin(admin.ModelAdmin):
list_display = ('switch', 'port','details')
list_display = ('switch', 'port','room','details')
class RoomAdmin(admin.ModelAdmin):
list_display = ('building','room','number','details')

2
users/admin.py

@ -3,7 +3,7 @@ from django.contrib import admin
from .models import User, School, Right, ListRight, Ban
class UserAdmin(admin.ModelAdmin):
list_display = ('name','surname','pseudo','email', 'school', 'state')
list_display = ('name','surname','pseudo','room','email', 'school', 'state')
class SchoolAdmin(admin.ModelAdmin):
list_display = ('name',)

10
users/models.py

@ -1,9 +1,11 @@
from django.db import models
from django.forms import ModelForm
from django.forms import ModelForm, Form
from django import forms
from django.utils import timezone
from topologie.models import Room
class User(models.Model):
STATE_ACTIVE = 0
STATE_DEACTIVATED = 1
@ -20,6 +22,7 @@ class User(models.Model):
email = models.EmailField()
school = models.ForeignKey('School', on_delete=models.PROTECT)
promo = models.CharField(max_length=255)
room = models.OneToOneField('topologie.Room', on_delete=models.PROTECT, blank=True, null=True)
pwd_ssha = models.CharField(max_length=255)
pwd_ntlm = models.CharField(max_length=255)
state = models.IntegerField(choices=STATES, default=STATE_ACTIVE)
@ -79,7 +82,7 @@ class InfoForm(ModelForm):
class Meta:
model = User
fields = ['name','surname','pseudo','email', 'school', 'promo']
fields = ['name','surname','pseudo','email', 'school', 'promo', 'room']
class PasswordForm(ModelForm):
class Meta:
@ -127,3 +130,6 @@ class BanForm(ModelForm):
if date_end < timezone.now():
raise forms.ValidationError("Triple buse, la date de fin ne peut pas être avant maintenant... Re2o ne voyage pas dans le temps")
return date_end
class ProfilForm(Form):
user =forms.CharField(label ='Ok', max_length=100)

Loading…
Cancel
Save