From dde4d6a1123f7ebb6d7de164e7d462bb7167119a Mon Sep 17 00:00:00 2001 From: chirac Date: Sat, 2 Jul 2016 21:57:31 +0200 Subject: [PATCH] Ajoute une table ban --- users/admin.py | 6 ++++- users/migrations/0006_ban.py | 25 ++++++++++++++++++ .../__pycache__/0006_ban.cpython-34.pyc | Bin 0 -> 1037 bytes users/models.py | 19 ++++++++++++- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 users/migrations/0006_ban.py create mode 100644 users/migrations/__pycache__/0006_ban.cpython-34.pyc diff --git a/users/admin.py b/users/admin.py index 1336498a..cbbcbf98 100644 --- a/users/admin.py +++ b/users/admin.py @@ -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) diff --git a/users/migrations/0006_ban.py b/users/migrations/0006_ban.py new file mode 100644 index 00000000..99b71511 --- /dev/null +++ b/users/migrations/0006_ban.py @@ -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')), + ], + ), + ] diff --git a/users/migrations/__pycache__/0006_ban.cpython-34.pyc b/users/migrations/__pycache__/0006_ban.cpython-34.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e23b0a97a347b9517636ceb17c3acb6941b19656 GIT binary patch literal 1037 zcmZ`&&2G~`5FY=;i5;h;KwAnNkWd8X5Qj<>sY0lbQb4FJqCrTxtTx$g>foQScG@P_ z@&-HwkHKr~l~XS~02i2DE0hB`-qGy0Gqc|}p8W6|-j~~FAG#L6clhhE(ci|EAE06Q z8V~~{2J{Uu)ZT>Hgv5fr1&IxPyF@LBE6{h~C9{E5;4=nRfLk!G!a2rPfmv`EI2TwH z0z)>ZX*A3jCvjA8LE}6yrI$n_L5nC$bLk{_80Y~B0v(Amb7e?!ATF+xIp6WC1{ zAwdhc4daTss${_&;Etle@T~!JfqB5{z&WX-6U+>8JL_`S{GxCwoq$6mQXDN1_o{^ZRqvH7D7xqp|QyME3YRC8lZ{+DP;<>=#1zGQE$$M&Igsl+w88&cN zbxFG2V=79wv4g^TQNqiux0?wbjnX%&8Ej0`Q6^0`KvhZtPNA&6eRt4%(d|huo8XY@ z$@~i9K3<{C&j;ZN72)aWX(;$c7HYlW4JBl31G!wANDI`X8`e{!Q8o%Hl32>0*~GOD|B>YER0pK2^1I L2TjvlHGJzgD!3H# literal 0 HcmV?d00001 diff --git a/users/models.py b/users/models.py index 333ac569..86b3b7dd 100644 --- a/users/models.py +++ b/users/models.py @@ -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']