diff --git a/symposion/schedule/admin.py b/symposion/schedule/admin.py index 708ea131..7cf59ecb 100644 --- a/symposion/schedule/admin.py +++ b/symposion/schedule/admin.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from django.contrib import admin -from symposion.schedule.models import Schedule, Day, Room, SlotKind, Slot, SlotRoom, Presentation, Session, SessionRole +from symposion.schedule.models import Schedule, Day, Room, SlotKind, Slot, SlotRoom, Presentation, Session, SessionRole, Track class DayInline(admin.StackedInline): @@ -55,3 +55,4 @@ admin.site.register(Slot, SlotAdmin) admin.site.register(Session) admin.site.register(SessionRole) admin.site.register(Presentation, PresentationAdmin) +admin.site.register(Track) diff --git a/symposion/schedule/migrations/0007_auto_20161224_1709.py b/symposion/schedule/migrations/0007_auto_20161224_1709.py new file mode 100644 index 00000000..2ddbfafb --- /dev/null +++ b/symposion/schedule/migrations/0007_auto_20161224_1709.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-12-24 06:09 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('symposion_schedule', '0006_room_track'), + ] + + operations = [ + migrations.CreateModel( + name='Track', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=80, verbose_name='Track')), + ('day', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='symposion_schedule.Day')), + ], + options={ + 'verbose_name': 'Track', + 'verbose_name_plural': 'Tracks', + }, + ), + migrations.RemoveField( + model_name='room', + name='track', + ), + migrations.AddField( + model_name='track', + name='room', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='symposion_schedule.Room'), + ), + migrations.AlterUniqueTogether( + name='track', + unique_together=set([('room', 'day')]), + ), + ] diff --git a/symposion/schedule/models.py b/symposion/schedule/models.py index 0ee60677..a5074252 100644 --- a/symposion/schedule/models.py +++ b/symposion/schedule/models.py @@ -51,17 +51,31 @@ class Room(models.Model): schedule = models.ForeignKey(Schedule, verbose_name=_("Schedule")) name = models.CharField(max_length=65, verbose_name=_("Name")) - track = models.CharField(max_length=80, verbose_name=_("Track"), default=None, blank=True, null=True) order = models.PositiveIntegerField(verbose_name=_("Order")) def __str__(self): - return '%s (%s)' % (self.name, self.track) + return self.name class Meta: verbose_name = _("Room") verbose_name_plural = _("Rooms") +@python_2_unicode_compatible +class Track(models.Model): + name = models.CharField(max_length=80, verbose_name=_("Track")) + room = models.ForeignKey(Room) + day = models.ForeignKey(Day) + + def __str__(self): + return self.name + + class Meta: + unique_together = [('room', 'day')] + verbose_name = _("Track") + verbose_name_plural = _("Tracks") + + @python_2_unicode_compatible class SlotKind(models.Model): """