diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index 8987a7a..5eece00 100644 Binary files a/blechreiz/database.sqlite and b/blechreiz/database.sqlite differ diff --git a/blechreiz/urls.py b/blechreiz/urls.py index b2a00fe..80bb9bf 100644 --- a/blechreiz/urls.py +++ b/blechreiz/urls.py @@ -17,6 +17,7 @@ from django.conf.urls.static import static admin.autodiscover() urlpatterns = patterns('', + url(r'$^', website.views.home_view), url(r'^events/', include( eventplanner.urls.urlpatterns) ), url(r'^admin/', include(admin.site.urls) ), url(r'^admin/doc/', include('django.contrib.admindocs.urls') ), @@ -24,7 +25,6 @@ urlpatterns = patterns('', url(r'^musicians/$', MusicianList.as_view() ), url(r'^musicians/(?P[\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):