diff --git a/mercantile/migrations/0001_initial.py b/mercantile/migrations/0001_initial.py index fe28078..f56591d 100644 --- a/mercantile/migrations/0001_initial.py +++ b/mercantile/migrations/0001_initial.py @@ -2,21 +2,18 @@ from __future__ import unicode_literals from django.db import models, migrations -from django.conf import settings class Migration(migrations.Migration): dependencies = [ - ('waffles', '0001_initial'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Calculation', fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('amount', models.IntegerField(verbose_name='Amount owed')), ('date', models.DateTimeField(verbose_name='Date integrated')), ], @@ -28,12 +25,8 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Debt', fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('amount', models.BigIntegerField(verbose_name='Amount owed')), - ( - 'debtee', models.ForeignKey(verbose_name='Debtee', related_name='debtee', to=settings.AUTH_USER_MODEL)), - ( - 'debtor', models.ForeignKey(verbose_name='Debtor', related_name='debtor', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Total debt', @@ -43,24 +36,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Settlement', fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('date', models.DateField(verbose_name='Date made')), ('amount', models.IntegerField(verbose_name='Amount owed')), - ('debt', models.ForeignKey(verbose_name='Connected debt', to='mercantile.Debt')), + ('debt', models.ForeignKey(to='mercantile.Debt', verbose_name='Connected debt')), ], options={ 'verbose_name': 'Cash settlement', 'verbose_name_plural': 'Cash settlements', }, ), - migrations.AddField( - model_name='calculation', - name='debt', - field=models.ForeignKey(verbose_name='Connected debt', to='mercantile.Debt'), - ), - migrations.AddField( - model_name='calculation', - name='event', - field=models.ForeignKey(to_field='Connected event', to='waffles.Event'), - ), ] diff --git a/mercantile/migrations/0002_auto_20150920_1158.py b/mercantile/migrations/0002_auto_20150920_1158.py new file mode 100644 index 0000000..93ef79e --- /dev/null +++ b/mercantile/migrations/0002_auto_20150920_1158.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings + + +class Migration(migrations.Migration): + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('mercantile', '0001_initial'), + ('waffles', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='debt', + name='debtee', + field=models.ForeignKey(related_name='debtee', to=settings.AUTH_USER_MODEL, verbose_name='Debtee'), + ), + migrations.AddField( + model_name='debt', + name='debtor', + field=models.ForeignKey(related_name='debtor', to=settings.AUTH_USER_MODEL, verbose_name='Debtor'), + ), + migrations.AddField( + model_name='calculation', + name='debt', + field=models.ForeignKey(to='mercantile.Debt', verbose_name='Connected debt'), + ), + migrations.AddField( + model_name='calculation', + name='event', + field=models.ForeignKey(to='waffles.Event', verbose_name='Connected event'), + ), + ] diff --git a/mercantile/models.py b/mercantile/models.py index 1c6d324..a24aa3a 100644 --- a/mercantile/models.py +++ b/mercantile/models.py @@ -25,7 +25,7 @@ class Calculation(models.Model): This is a single calculation of debt from an event. """ debt = models.ForeignKey(Debt, verbose_name=_("Connected debt")) - event = models.ForeignKey(Event, _("Connected event")) + event = models.ForeignKey(Event, verbose_name=_("Connected event")) amount = models.IntegerField(verbose_name=_("Amount owed")) date = models.DateTimeField(verbose_name=_("Date integrated")) diff --git a/vafling/settings.py b/vafling/settings.py index 32d0589..bfd9992 100644 --- a/vafling/settings.py +++ b/vafling/settings.py @@ -97,6 +97,7 @@ USE_L10N = True USE_TZ = True +LOGIN_URL = '/accounts/login/' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ diff --git a/vafling/urls.py b/vafling/urls.py index bd8fab3..e27e7db 100644 --- a/vafling/urls.py +++ b/vafling/urls.py @@ -17,5 +17,6 @@ from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ + url(r'^$', 'waffles.views.dashboard'), url(r'^admin/', include(admin.site.urls)), ] diff --git a/waffles/migrations/0001_initial.py b/waffles/migrations/0001_initial.py index 83269f8..a64cf17 100644 --- a/waffles/migrations/0001_initial.py +++ b/waffles/migrations/0001_initial.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals from django.db import models, migrations -import django.contrib.auth.models -import django.utils.timezone -import django.core.validators from django.conf import settings +import django.contrib.auth.models +import django.core.validators +import django.utils.timezone class Migration(migrations.Migration): @@ -18,40 +18,38 @@ class Migration(migrations.Migration): migrations.CreateModel( name='UserProfile', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, verbose_name='last login', null=True)), - ('is_superuser', models.BooleanField(default=False, - help_text='Designates that this user has all permissions without explicitly assigning them.', - verbose_name='superuser status')), - ('username', models.CharField(max_length=30, verbose_name='username', validators=[ - django.core.validators.RegexValidator('^[\\w.@+-]+$', - 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', - 'invalid')], unique=True, - help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', - error_messages={'unique': 'A user with that username already exists.'})), + ('last_login', models.DateTimeField(null=True, blank=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, verbose_name='superuser status', + help_text='Designates that this user has all permissions without explicitly assigning them.')), + ('username', + models.CharField(max_length=30, error_messages={'unique': 'A user with that username already exists.'}, + verbose_name='username', validators=[ + django.core.validators.RegexValidator('^[\\w.@+-]+$', + 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', + 'invalid')], unique=True, + help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.')), ('first_name', models.CharField(max_length=30, blank=True, verbose_name='first name')), ('last_name', models.CharField(max_length=30, blank=True, verbose_name='last name')), ('email', models.EmailField(max_length=254, blank=True, verbose_name='email address')), - ('is_staff', models.BooleanField(default=False, - help_text='Designates whether the user can log into this admin site.', - verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, - help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', - verbose_name='active')), + ('is_staff', models.BooleanField(default=False, verbose_name='staff status', + help_text='Designates whether the user can log into this admin site.')), + ('is_active', models.BooleanField(default=True, verbose_name='active', + help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('groups', - models.ManyToManyField(related_query_name='user', verbose_name='groups', related_name='user_set', - help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', - blank=True, to='auth.Group')), - ('user_permissions', models.ManyToManyField(related_query_name='user', verbose_name='user permissions', - related_name='user_set', - help_text='Specific permissions for this user.', blank=True, - to='auth.Permission')), + ('groups', models.ManyToManyField(related_name='user_set', + help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', + to='auth.Group', blank=True, verbose_name='groups', + related_query_name='user')), + ('user_permissions', + models.ManyToManyField(related_name='user_set', help_text='Specific permissions for this user.', + to='auth.Permission', blank=True, verbose_name='user permissions', + related_query_name='user')), ], options={ - 'verbose_name_plural': 'User profiles', 'verbose_name': 'User profile', + 'verbose_name_plural': 'User profiles', }, managers=[ ('objects', django.contrib.auth.models.UserManager()), @@ -60,76 +58,76 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Community', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('name', models.CharField(max_length=64, verbose_name='Community name')), - ('members', models.ManyToManyField(verbose_name='Community members', to=settings.AUTH_USER_MODEL)), + ('members', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Community members')), ], options={ - 'verbose_name_plural': 'Communities', 'verbose_name': 'Community', + 'verbose_name_plural': 'Communities', }, ), migrations.CreateModel( name='Event', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('name', models.CharField(max_length=64, verbose_name='Event name')), ('description', models.TextField(verbose_name='Description/text')), ('open', models.BooleanField(verbose_name='Open for new participants')), ('status', models.BooleanField(verbose_name='Finalized')), ('timeFrom', models.DateTimeField(verbose_name='Start time')), ('timeTo', models.DateTimeField(verbose_name='End time')), - ('participants', models.ManyToManyField(verbose_name='Participants', to=settings.AUTH_USER_MODEL)), + ('participants', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Participants')), ], options={ - 'verbose_name_plural': 'Events', 'verbose_name': 'Event', + 'verbose_name_plural': 'Events', }, ), migrations.CreateModel( name='Listing', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('timeFrom', models.DateTimeField(verbose_name='Start time')), ('timeTo', models.DateTimeField(verbose_name='End time')), ('description', models.TextField(verbose_name='Description/text')), - ('community', models.ForeignKey(verbose_name='Community', to='waffles.Community')), - ('user', models.ForeignKey(verbose_name='Requesting user', to=settings.AUTH_USER_MODEL)), + ('community', models.ForeignKey(to='waffles.Community', verbose_name='Community')), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, verbose_name='Requesting user')), ], options={ - 'verbose_name_plural': 'Listing', 'verbose_name': 'Listing', + 'verbose_name_plural': 'Listing', }, ), migrations.CreateModel( name='ShoppingList', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('name', models.CharField(max_length=64, verbose_name='Name')), ('price', models.IntegerField(verbose_name='Price')), - ('payers', models.ManyToManyField(verbose_name='Payers', to=settings.AUTH_USER_MODEL)), + ('payers', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Payers')), ], options={ - 'verbose_name_plural': 'Shopping lists', 'verbose_name': 'Shopping list', + 'verbose_name_plural': 'Shopping lists', }, ), migrations.CreateModel( name='SubEvent', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), ('name', models.CharField(max_length=64, verbose_name='Name')), - ('event', models.ForeignKey(verbose_name='Parent event', to='waffles.Event')), - ('participants', models.ManyToManyField(verbose_name='Participants', to=settings.AUTH_USER_MODEL)), + ('event', models.ForeignKey(to='waffles.Event', verbose_name='Parent event')), + ('participants', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Participants')), ], options={ - 'verbose_name_plural': 'Sub Events', 'verbose_name': 'Sub Event', + 'verbose_name_plural': 'Sub Events', }, ), migrations.AddField( model_name='shoppinglist', name='subevent', - field=models.ForeignKey(verbose_name='Connected sub-event', to='waffles.SubEvent'), + field=models.ForeignKey(to='waffles.SubEvent', verbose_name='Connected sub-event'), ), ] diff --git a/waffles/models.py b/waffles/models.py index 9ada25f..499cb2d 100644 --- a/waffles/models.py +++ b/waffles/models.py @@ -64,6 +64,9 @@ class Event(models.Model): verbose_name = _('Event') verbose_name_plural = _('Events') + def __str__(self): + return "".format(name=self.name) + class SubEvent(models.Model): """ diff --git a/waffles/views.py b/waffles/views.py index 60f00ef..1696b8e 100644 --- a/waffles/views.py +++ b/waffles/views.py @@ -1 +1,12 @@ # Create your views here. +from django.utils import timezone +from django.contrib.auth.decorators import login_required +from django.http import HttpResponse + +from waffles.models import * + + +@login_required +def dashboard(request): + events = Event.objects.filter(timeTo__gt=timezone.now()).all() + return HttpResponse([e for e in events], content_type="text/plain")