From e66d46127b1628f63485b12cc0a304c119228251 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 16 Jul 2019 09:17:57 +0200 Subject: [PATCH] Fix adh migration --- adherents/migrations/0001_initial.py | 10 ++++++++-- adherents/models.py | 18 +++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/adherents/migrations/0001_initial.py b/adherents/migrations/0001_initial.py index 9b0992c9..32433430 100644 --- a/adherents/migrations/0001_initial.py +++ b/adherents/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.3 on 2019-07-08 11:48 +# Generated by Django 2.2.3 on 2019-07-16 07:17 from django.conf import settings from django.db import migrations, models @@ -18,8 +18,14 @@ class Migration(migrations.Migration): name='Profile', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('phone_number', models.CharField(max_length=255, verbose_name='phone number')), + ('avatar', models.ImageField(blank=True, max_length=255, upload_to='', verbose_name='profile picture')), + ('phone_number', models.CharField(blank=True, default='', max_length=50, null=True, verbose_name='phone number')), ('section', models.CharField(help_text='e.g. "1A0", "9A♥", "SAPHIRE"', max_length=255, verbose_name='section')), + ('genre', models.CharField(blank=True, choices=[(None, 'ND'), ('M', 'M'), ('F', 'F')], max_length=1, null=True)), + ('address', models.TextField(blank=True, null=True)), + ('paid', models.BooleanField(default=False, verbose_name='paid')), + ('is_active', models.BooleanField(default=True, verbose_name='is active')), + ('is_deleted', models.BooleanField(default=False, verbose_name='is deleted')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ diff --git a/adherents/models.py b/adherents/models.py index d473b680..947499bd 100644 --- a/adherents/models.py +++ b/adherents/models.py @@ -35,7 +35,7 @@ class Profile(models.Model): phone_number = models.CharField( max_length=50, blank=True, - null=False, + null=True, default='', verbose_name=_('phone number'), ) @@ -46,15 +46,13 @@ class Profile(models.Model): ) genre = models.CharField( max_length=1, - blank=False, - null=False, + blank=True, + null=True, choices=GENRES, - default=None, ) address = models.TextField( blank=True, - null=False, - default='', + null=True, ) paid = models.BooleanField( verbose_name=_("paid"), @@ -73,9 +71,6 @@ class Profile(models.Model): verbose_name = _('user profile') verbose_name_plural = _('user profile') - def __str__(self): - return self.user.get_username() - class MembershipFee(models.Model): """ @@ -99,12 +94,9 @@ class MembershipFee(models.Model): verbose_name = _('membership fee') verbose_name_plural = _('membership fees') - def __str__(self): - return self.user.get_username() - @receiver(post_save, sender=User) -def save_user_profile(sender, instance, created, **_kwargs): +def save_user_profile(instance, created, **_kwargs): """ Hook to save an user profile when an user is updated """