From 49ba4e52233b31a005177fd2fc5ad9f52425a4bb Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 15 Sep 2013 14:48:40 +0200 Subject: [PATCH] Landing Page for internal area --- blechreiz/database.sqlite | Bin 53248 -> 53248 bytes blechreiz/urls.py | 2 +- eventplanner/models.py | 19 ++++- eventplanner/views.py | 1 - website/templates/website/base.html | 10 ++- website/templates/website/mainpage.html | 92 ++++++++++++++++++++---- website/views.py | 19 ++++- 7 files changed, 120 insertions(+), 23 deletions(-) diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index 8987a7ac2ec88797c21970afe6f4040f3b19a9b6..5eece000b5c135117666b8eee59f6d08aab6dca1 100644 GIT binary patch delta 817 zcma))-%Aux6vyw~@9gZX?xwa%iEU0u__R8Ac6WaGk|NQD>Gr5El8z&r>+a}IBKDHj zKVZy1AVv@bLJU+8R4;)L^x{h*A_x*~1QqpQy>w?+ed)pAa_^UWzMpgM;oRjlEU#g; zgN{DDFi1zA-Flpk&_hBGLr;Ac`%0yiUK%GW-2kUOoccLw@k2qFA9<|bc z-QI5T^4U!yVjcL24ea6rm!JHW)*7(A0m zX`{&RDYu8XpAab=*qY+F(kRsfLJ(*`ov!Hs#1_F1RB?!X>|l$ReuJinKq(bMk|@w9 z6(at=yV|SN2Ur`vmeCAdmo8#}9`~%CgpD4i=uFS}>yIX5%_6pe@A!h>IKUpZd4YF` zg~9VnwLRh;_?_IgNAL&Vxak*v%^tVCM`K_JNdlrY;#FUapE~gW`DiaCvGbJQ<$ccW Nw3?}ZTUvkH{1;-%*3kd} delta 618 zcmZozz}&Ead4e>f(L@<%Mx%`hOO4r?7#Nrsm{xB#8k?9HS~LkWvHCWfI!@m0udw-*hdeW@GIK7o$7VhsNoED3w9>qce9Nqiq+G)) z(~`2}^n%0+i;ATDtlY|?QX|vJ?*9G+?cKc1-&=y40q6nd6%5QPm~UMU|P8Ve;K{wB|U+LN-#3=^D;BpgPEK_CWyt!#>M~@=U@dg!Qx!ZAeJyMNIMr$ z5exGp2If!9ub6)_KLR@G0y7gYxWMF8lYhbBs z1eZ3}Gch+YG_u^hXmJt`4-4~CX6BE~ubF=_KLwh1m3i{h&GJCeR}9R*nLjXpWq!3; lQ04|R6F1Z3SKH$V1{*QawS$9=a2&nzxFv$k)r$@Y001j[\w]+)$', user_edit ), url(r'^admin_area/$', intern_area.views.login_site ), - url(r'^website/$', website.views.home_view), url(r'^login/$', website.views.login_view), url(r'^logout/$', website.views.logout_view), url(r'^messages/$', messages.views.message_view ), diff --git a/eventplanner/models.py b/eventplanner/models.py index 23343b7..0288522 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -3,6 +3,7 @@ from django.utils.translation import ugettext as _ from musicians.models import Musician +from datetime import datetime class Event ( models.Model ): @@ -36,7 +37,13 @@ class Event ( models.Model ): for m in Musician.objects.all(): if not m in self.participants.all(): EventParticipation.objects.create( event=self, musician = m, status='?', comment = '' ) - + + @property + def displaytime(self): + if self.meeting_time is None or self.meeting_time == "": + return self.time + else: + return self.meeting_time @@ -56,6 +63,16 @@ class EventParticipation( models.Model ): def get_musician_username(self): return self.musician.user.username + @staticmethod + def hasUserSetParticipationForAllEvents( user ): + futurePart = EventParticipation.objects.filter( event__date__gte = datetime.now() ) + maybeObjects = futurePart.filter( musician__user = user ).filter( status = '?' ) + + if len( maybeObjects ) > 0: + return False + else: + return True + @staticmethod def get_or_create( musician , event ): diff --git a/eventplanner/views.py b/eventplanner/views.py index 463f9ae..8b3c1a7 100644 --- a/eventplanner/views.py +++ b/eventplanner/views.py @@ -73,7 +73,6 @@ def eventplanning( request ): # All events in the future sorted by date all_future_events = list ( Event.objects.filter( date__gte = datetime.date.today() ) ) - musician = get_object_or_404( Musician, user=request.user ) for e in all_future_events: diff --git a/website/templates/website/base.html b/website/templates/website/base.html index 4bebff4..3f93b0b 100644 --- a/website/templates/website/base.html +++ b/website/templates/website/base.html @@ -103,8 +103,7 @@ $.ajaxSetup({ diff --git a/website/templates/website/mainpage.html b/website/templates/website/mainpage.html index beeed58..7a6de18 100644 --- a/website/templates/website/mainpage.html +++ b/website/templates/website/mainpage.html @@ -4,7 +4,71 @@ {% load sekizai_tags staticfiles %} +{% block feature_slider %} + + {% addtoblock "css" %} + + {% endaddtoblock %} + +
+
+
+ Einsatzplanung +
+ {% if hasParticipationSetForAllEvents %} + Sehr gut - du hast dich für alles eingetragen + {% else %} + Du hast dich noch nicht für alle Termine eingetragen!! + {% endif %} +
+
+
+ +
+ +
+ Forum +
Nachricht an alle schreiben...
+
+
+
+{% endblock %} {% block content %} @@ -15,14 +79,9 @@ {% addtoblock "js" %} {% endaddtoblock %} @@ -48,11 +107,18 @@
-

Unser nächstes Konzert

+

Der nächste Termin:

- Ist in Rohr um 19:00 in der Was WeissIch Kirche Bis dann -
- Dorfplatz 5, Rohr + {{event.title}} ist am {{event.date}} um {{event.displaytime | time:"H:i" }} in {{event.location}} + +
+ {% if participation == "?" %} + Du hast dich noch nicht für diesen Termin eingetragen! + {% elif participation == "Yes" %} + Du hast für diesen Termin zugesagt. + {% elif participation == "No" %} + Du hast für diesen Termin abgesagt. + {%endif %}

diff --git a/website/views.py b/website/views.py index 4526578..21dfc57 100644 --- a/website/views.py +++ b/website/views.py @@ -9,8 +9,25 @@ from django.http import HttpResponse from django.utils import simplejson +from eventplanner.models import Event, EventParticipation + +from datetime import datetime + def home_view(request): - return render( request, 'website/mainpage.html' ) + events = Event.objects.filter( date__gte = datetime.now() ).order_by('date')[:1] + context = dict() + + + part = EventParticipation.objects.filter( musician__user = request.user ).filter( event = events[0] ) + + eventTime = datetime( events[0].date.year, events[0].date.month, events[0].date.day, + events[0].displaytime.hour, events[0].displaytime.minute ) + + context['hasParticipationSetForAllEvents'] = EventParticipation.hasUserSetParticipationForAllEvents( request.user) + context['event'] = events[0] + context['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 ) + context['participation'] = part[0].status + return render( request, 'website/mainpage.html', context ) def logout_view(request):