mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Ajoute une table ban
This commit is contained in:
parent
f502e59360
commit
dde4d6a112
4 changed files with 48 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import User, School, Right, ListRight
|
||||
from .models import User, School, Right, ListRight, Ban
|
||||
|
||||
class UserAdmin(admin.ModelAdmin):
|
||||
list_display = ('name','surname','pseudo','email', 'school', 'state')
|
||||
|
@ -14,7 +14,11 @@ class ListRightAdmin(admin.ModelAdmin):
|
|||
class RightAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'right')
|
||||
|
||||
class BanAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'raison', 'date_start', 'date_end')
|
||||
|
||||
admin.site.register(User, UserAdmin)
|
||||
admin.site.register(School, SchoolAdmin)
|
||||
admin.site.register(Right, RightAdmin)
|
||||
admin.site.register(ListRight, ListRightAdmin)
|
||||
admin.site.register(Ban, BanAdmin)
|
||||
|
|
25
users/migrations/0006_ban.py
Normal file
25
users/migrations/0006_ban.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0005_auto_20160702_0006'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Ban',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)),
|
||||
('raison', models.CharField(max_length=255)),
|
||||
('date_start', models.DateTimeField(help_text='%m/%d/%y %H:%M:%S')),
|
||||
('date_end', models.DateTimeField(help_text='%m/%d/%y %H:%M:%S')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.User')),
|
||||
],
|
||||
),
|
||||
]
|
BIN
users/migrations/__pycache__/0006_ban.cpython-34.pyc
Normal file
BIN
users/migrations/__pycache__/0006_ban.cpython-34.pyc
Normal file
Binary file not shown.
|
@ -20,7 +20,6 @@ class User(models.Model):
|
|||
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)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -48,6 +47,15 @@ class ListRight(models.Model):
|
|||
def __str__(self):
|
||||
return self.listright
|
||||
|
||||
class Ban(models.Model):
|
||||
user = models.ForeignKey('User', on_delete=models.PROTECT)
|
||||
raison = models.CharField(max_length=255)
|
||||
date_start = models.DateTimeField(help_text='%m/%d/%y %H:%M:%S')
|
||||
date_end = models.DateTimeField(help_text='%m/%d/%y %H:%M:%S')
|
||||
|
||||
def __str__(self):
|
||||
return str(self.user) + ' ' + str(self.raison)
|
||||
|
||||
class UserForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(InfoForm, self).__init__(*args, **kwargs)
|
||||
|
@ -102,3 +110,12 @@ class DelRightForm(ModelForm):
|
|||
model = Right
|
||||
exclude = ['user', 'right']
|
||||
|
||||
class BanForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BanForm, self).__init__(*args, **kwargs)
|
||||
self.fields['date_start'].label = 'Date de début'
|
||||
self.fields['date_end'].label = 'Date de fin'
|
||||
|
||||
class Meta:
|
||||
model = Ban
|
||||
exclude = ['user']
|
||||
|
|
Loading…
Reference in a new issue