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

Ajoute une table ban

This commit is contained in:
chirac 2016-07-02 21:57:31 +02:00
parent f502e59360
commit dde4d6a112
4 changed files with 48 additions and 2 deletions

View file

@ -1,6 +1,6 @@
from django.contrib import admin from django.contrib import admin
from .models import User, School, Right, ListRight from .models import User, School, Right, ListRight, Ban
class UserAdmin(admin.ModelAdmin): class UserAdmin(admin.ModelAdmin):
list_display = ('name','surname','pseudo','email', 'school', 'state') list_display = ('name','surname','pseudo','email', 'school', 'state')
@ -14,7 +14,11 @@ class ListRightAdmin(admin.ModelAdmin):
class RightAdmin(admin.ModelAdmin): class RightAdmin(admin.ModelAdmin):
list_display = ('user', 'right') list_display = ('user', 'right')
class BanAdmin(admin.ModelAdmin):
list_display = ('user', 'raison', 'date_start', 'date_end')
admin.site.register(User, UserAdmin) admin.site.register(User, UserAdmin)
admin.site.register(School, SchoolAdmin) admin.site.register(School, SchoolAdmin)
admin.site.register(Right, RightAdmin) admin.site.register(Right, RightAdmin)
admin.site.register(ListRight, ListRightAdmin) admin.site.register(ListRight, ListRightAdmin)
admin.site.register(Ban, BanAdmin)

View 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')),
],
),
]

Binary file not shown.

View file

@ -20,7 +20,6 @@ class User(models.Model):
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)
state = models.IntegerField(choices=STATES, default=STATE_ACTIVE) state = models.IntegerField(choices=STATES, default=STATE_ACTIVE)
def __str__(self): def __str__(self):
@ -48,6 +47,15 @@ class ListRight(models.Model):
def __str__(self): def __str__(self):
return self.listright 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): class UserForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(InfoForm, self).__init__(*args, **kwargs) super(InfoForm, self).__init__(*args, **kwargs)
@ -102,3 +110,12 @@ class DelRightForm(ModelForm):
model = Right model = Right
exclude = ['user', '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']