diff --git a/launderette/admin.py b/launderette/admin.py index 8c38f3f3..3f7c0d27 100644 --- a/launderette/admin.py +++ b/launderette/admin.py @@ -1,3 +1,9 @@ from django.contrib import admin +from launderette.models import * + # Register your models here. +admin.site.register(Launderette) +admin.site.register(Machine) +admin.site.register(Token) +admin.site.register(Slot) diff --git a/launderette/migrations/0001_initial.py b/launderette/migrations/0001_initial.py deleted file mode 100644 index deacb3bd..00000000 --- a/launderette/migrations/0001_initial.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Launderette', - fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(max_length=30, verbose_name='name')), - ], - options={ - 'verbose_name': 'Launderette', - }, - ), - migrations.CreateModel( - name='Machine', - fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(max_length=30, verbose_name='name')), - ('is_working', models.BooleanField(default=True, verbose_name='is working')), - ('launderette', models.ForeignKey(to='launderette.Launderette', related_name='machines', verbose_name='launderette')), - ], - options={ - 'verbose_name': 'Machine', - }, - ), - migrations.CreateModel( - name='Token', - fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(max_length=30, verbose_name='name')), - ('type', models.CharField(choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10, verbose_name='type')), - ('launderette', models.ForeignKey(to='launderette.Launderette', related_name='tokens', verbose_name='launderette')), - ], - options={ - 'verbose_name': 'Token', - }, - ), - ] diff --git a/launderette/migrations/0001_squashed_0006_auto_20160729_0050.py b/launderette/migrations/0001_squashed_0006_auto_20160729_0050.py new file mode 100644 index 00000000..d447b26b --- /dev/null +++ b/launderette/migrations/0001_squashed_0006_auto_20160729_0050.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + replaces = [('launderette', '0001_initial'), ('launderette', '0002_auto_20160728_1858'), ('launderette', '0003_launderette_sellers'), ('launderette', '0004_auto_20160728_1922'), ('launderette', '0005_auto_20160729_0049'), ('launderette', '0006_auto_20160729_0050')] + + dependencies = [ + ('subscription', '0002_auto_20160718_1805'), + ] + + operations = [ + migrations.CreateModel( + name='Launderette', + fields=[ + ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('name', models.CharField(verbose_name='name', max_length=30)), + ], + options={ + 'verbose_name': 'Launderette', + }, + ), + migrations.CreateModel( + name='Machine', + fields=[ + ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('name', models.CharField(verbose_name='name', max_length=30)), + ('is_working', models.BooleanField(verbose_name='is working', default=True)), + ('launderette', models.ForeignKey(related_name='machines', verbose_name='launderette', to='launderette.Launderette')), + ], + options={ + 'verbose_name': 'Machine', + }, + ), + migrations.CreateModel( + name='Token', + fields=[ + ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('name', models.IntegerField(verbose_name='name')), + ('type', models.CharField(verbose_name='type', choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10)), + ('launderette', models.ForeignKey(related_name='tokens', verbose_name='launderette', to='launderette.Launderette')), + ], + options={ + 'verbose_name': 'Token', + }, + ), + migrations.CreateModel( + name='Slot', + fields=[ + ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('start_date', models.DateTimeField(verbose_name='start date')), + ('type', models.CharField(verbose_name='type', choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10)), + ('machine', models.ForeignKey(related_name='slots', verbose_name='machine', to='launderette.Machine')), + ('token', models.ForeignKey(related_name='slots', null=True, verbose_name='token', blank=True, to='launderette.Token')), + ('user', models.ForeignKey(related_name='slots', verbose_name='user', to='subscription.Subscriber')), + ], + ), + migrations.AddField( + model_name='launderette', + name='sellers', + field=models.ManyToManyField(verbose_name='sellers', related_name='launderettes', blank=True, to='subscription.Subscriber'), + ), + ] diff --git a/launderette/migrations/0002_auto_20160728_1858.py b/launderette/migrations/0002_auto_20160728_1858.py deleted file mode 100644 index f8aa6b6d..00000000 --- a/launderette/migrations/0002_auto_20160728_1858.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('subscription', '0002_auto_20160718_1805'), - ('launderette', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Slot', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), - ('start_date', models.DateTimeField(verbose_name='start date')), - ('type', models.CharField(max_length=10, verbose_name='type', choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')])), - ('machine', models.ForeignKey(verbose_name='machine', related_name='slots', to='launderette.Machine')), - ], - ), - migrations.AlterField( - model_name='token', - name='name', - field=models.IntegerField(verbose_name='name'), - ), - migrations.AddField( - model_name='slot', - name='token', - field=models.ForeignKey(verbose_name='token', related_name='slots', to='launderette.Token'), - ), - migrations.AddField( - model_name='slot', - name='user', - field=models.ForeignKey(verbose_name='user', related_name='slots', to='subscription.Subscriber'), - ), - ] diff --git a/launderette/migrations/0002_auto_20160729_0138.py b/launderette/migrations/0002_auto_20160729_0138.py new file mode 100644 index 00000000..3d1cd8ec --- /dev/null +++ b/launderette/migrations/0002_auto_20160729_0138.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('launderette', '0001_squashed_0006_auto_20160729_0050'), + ] + + operations = [ + migrations.AlterModelOptions( + name='slot', + options={'verbose_name': 'Slot'}, + ), + ] diff --git a/launderette/migrations/0003_launderette_sellers.py b/launderette/migrations/0003_launderette_sellers.py deleted file mode 100644 index de418c0f..00000000 --- a/launderette/migrations/0003_launderette_sellers.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('subscription', '0002_auto_20160718_1805'), - ('launderette', '0002_auto_20160728_1858'), - ] - - operations = [ - migrations.AddField( - model_name='launderette', - name='sellers', - field=models.ManyToManyField(to='subscription.Subscriber', verbose_name='sellers', related_name='launderettes'), - ), - ] diff --git a/launderette/migrations/0004_auto_20160728_1922.py b/launderette/migrations/0004_auto_20160728_1922.py deleted file mode 100644 index 6bcbdbe8..00000000 --- a/launderette/migrations/0004_auto_20160728_1922.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('launderette', '0003_launderette_sellers'), - ] - - operations = [ - migrations.AlterField( - model_name='launderette', - name='sellers', - field=models.ManyToManyField(blank=True, to='subscription.Subscriber', verbose_name='sellers', related_name='launderettes'), - ), - ] diff --git a/launderette/models.py b/launderette/models.py index 945a9766..d458d2e2 100644 --- a/launderette/models.py +++ b/launderette/models.py @@ -48,6 +48,9 @@ class Machine(models.Model): return True return False + def __str__(self): + return "%s - Launderette: %s - Working: %s" % (self.name, self.launderette, self.is_working) + class Token(models.Model): name = models.IntegerField(_('name')) launderette = models.ForeignKey(Launderette, related_name='tokens', verbose_name=_('launderette')) @@ -68,9 +71,16 @@ class Slot(models.Model): start_date = models.DateTimeField(_('start date')) type = models.CharField(_('type'), max_length=10, choices=[('WASHING', _('Washing')), ('DRYING', _('Drying'))]) machine = models.ForeignKey(Machine, related_name='slots', verbose_name=_('machine')) - token = models.ForeignKey(Token, related_name='slots', verbose_name=_('token')) + token = models.ForeignKey(Token, related_name='slots', verbose_name=_('token'), blank=True, null=True) user = models.ForeignKey(Subscriber, related_name='slots', verbose_name=_('user')) + class Meta: + verbose_name = _('Slot') + def full_clean(self): return super(Slot, self).full_clean() + def __str__(self): + return str(self.user) + " - " + str(self.start_date) + + diff --git a/launderette/templates/launderette/launderette_book.jinja b/launderette/templates/launderette/launderette_book.jinja index af30c6c1..d7f54d01 100644 --- a/launderette/templates/launderette/launderette_book.jinja +++ b/launderette/templates/launderette/launderette_book.jinja @@ -4,13 +4,38 @@ {% trans %}Launderette{% endtrans %} {% endblock %} +{% macro choose(date) %} +
+{% endmacro %} + + {% block content %} {% if request.user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP) %} -{{ day|date('l') }} | + {% endfor %} +
---|
+ {% if hours[i] %} + {{ hours[i]|localtime|time(TIME_FORMAT) }} {{ choose(hours[i]) }} + {% endif %} + | + {% endfor %} +