Commit dde4d6a1 authored by chirac's avatar chirac

Ajoute une table ban

parent f502e593
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)
# -*- 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')),
],
),
]
......@@ -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']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment