8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 17:03:45 +00:00
re2o/users/models.py

58 lines
1.5 KiB
Python
Raw Normal View History

2016-06-30 01:39:07 +00:00
from django.db import models
from django.forms import ModelForm
class User(models.Model):
STATE_ACTIVE = 0
STATE_DEACTIVATED = 1
STATE_ARCHIVED = 2
STATES = (
2016-06-30 18:18:06 +00:00
(0, 'STATE_ACTIVE'),
(1, 'STATE_DEACTIVATED'),
(2, 'STATE_ARCHIVED'),
2016-06-30 01:39:07 +00:00
)
name = models.CharField(max_length=255)
surname = models.CharField(max_length=255)
pseudo = models.CharField(max_length=255, unique=True)
2016-06-30 01:39:07 +00:00
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.IntegerField(choices=STATES, default=STATE_ACTIVE)
2016-06-30 01:39:07 +00:00
def __str__(self):
return self.name
2016-06-30 01:39:07 +00:00
class School(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
2016-06-30 01:39:07 +00:00
class UserForm(ModelForm):
class Meta:
model = User
2016-06-30 01:46:31 +00:00
fields = '__all__'
class InfoForm(ModelForm):
class Meta:
model = User
2016-06-30 09:22:30 +00:00
fields = ['name','surname','pseudo','email', 'school', 'promo']
2016-06-30 01:46:31 +00:00
class PasswordForm(ModelForm):
class Meta:
model = User
fields = ['pwd_ssha','pwd_ntlm']
class ArchiveForm(ModelForm):
class Meta:
model = User
fields = ['state']
2016-06-30 01:39:07 +00:00
class SchoolForm(ModelForm):
class Meta:
model = School
fields = ['name']