transport_needed: BooleanField -> NullBooleanField

This commit is contained in:
Élie Bouttier 2016-10-05 20:53:05 +02:00
parent e7a1060667
commit 07ce34055f
4 changed files with 42 additions and 3 deletions

View File

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

View File

@ -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)

View File

@ -60,10 +60,14 @@
{% for transport in speaker.transport.all %}
{% if not forloop.first %}, {% endif %}
{{ transport }}
{% empty %}
Yes
{% endfor %}
</td>
{% elif speaker.need_transport is None %}
<td>?</td>
{% else %}
<td></td>
<td>No</td>
{% endif %}
{% if speaker.need_hosting %}
<td class="{% if speaker.hosting_booked %}success{% else %}warning{% endif %}">

View File

@ -27,7 +27,7 @@
<h2>{% trans "Preferences" %}</h2>
<ul>
<li><b>{% trans "Need transport:" %}</b> {{ participation.need_transport|yesno }}</li>
<li><b>{% trans "Need transport:" %}</b> {{ participation.need_transport|yesno:"Yes,No,Not specified" }}</li>
<li><b>{% trans "Arrival:" %}</b> {{ participation.arrival }}</li>
<li><b>{% trans "Departure:" %}</b> {{ participation.departure }}</li>
<li><b>{% trans "Ok to travel by:" %}</b> {% for transport in participation.transport.all %}{% if not forloop.first %}, {% endif %}{{ transport }}{% endfor %}</li>