From 07ce34055fef6b6783a1c043e293c2568a700fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Wed, 5 Oct 2016 20:53:05 +0200 Subject: [PATCH] transport_needed: BooleanField -> NullBooleanField --- .../migrations/0011_auto_20161005_1841.py | 35 +++++++++++++++++++ accounts/models.py | 2 +- .../templates/proposals/speaker_list.html | 6 +++- .../templates/proposals/user_details.html | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 accounts/migrations/0011_auto_20161005_1841.py diff --git a/accounts/migrations/0011_auto_20161005_1841.py b/accounts/migrations/0011_auto_20161005_1841.py new file mode 100644 index 0000000..e9bc300 --- /dev/null +++ b/accounts/migrations/0011_auto_20161005_1841.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-10-05 18:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +def transport_false_to_none(apps, schema_editor): + db_alias = schema_editor.connection.alias + Participation = apps.get_model('accounts', 'Participation') + for participation in Participation.objects.using(db_alias).all(): + if participation.need_transport == False: + participation.need_transport = None + participation.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0010_auto_20161003_1152'), + ] + + operations = [ + migrations.AlterField( + model_name='participation', + name='need_transport', + field=models.NullBooleanField(default=None, verbose_name='Need transport?'), + ), + migrations.RunPython(transport_false_to_none), + migrations.AlterField( + model_name='participation', + name='notes', + field=models.TextField(blank=True, default='', help_text='This field is only visible by organizers.', verbose_name='Notes'), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index f0461dc..16414bc 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -51,7 +51,7 @@ class Participation(PonyConfModel): user = models.ForeignKey(User) - need_transport = models.BooleanField(verbose_name=_('Need transport?'), default=False) + need_transport = models.NullBooleanField(verbose_name=_('Need transport?'), default=None) arrival = models.DateTimeField(blank=True, null=True) departure = models.DateTimeField(blank=True, null=True) transport = models.ManyToManyField(Transport, verbose_name=_("I'm ok to travel by"), blank=True) diff --git a/proposals/templates/proposals/speaker_list.html b/proposals/templates/proposals/speaker_list.html index 29c0ff4..3e39d1e 100644 --- a/proposals/templates/proposals/speaker_list.html +++ b/proposals/templates/proposals/speaker_list.html @@ -60,10 +60,14 @@ {% for transport in speaker.transport.all %} {% if not forloop.first %}, {% endif %} {{ transport }} + {% empty %} + Yes {% endfor %} + {% elif speaker.need_transport is None %} + ? {% else %} - — + No {% endif %} {% if speaker.need_hosting %} diff --git a/proposals/templates/proposals/user_details.html b/proposals/templates/proposals/user_details.html index 403fd56..f799cc5 100644 --- a/proposals/templates/proposals/user_details.html +++ b/proposals/templates/proposals/user_details.html @@ -27,7 +27,7 @@

{% trans "Preferences" %}