From 3fa4bdaafd5da2287b81a6fc4610a546c1eb4dd6 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 22 Sep 2013 17:53:18 +0200 Subject: [PATCH] Map on mainpage --- blechreiz/database.sqlite | Bin 56320 -> 56320 bytes .../eventplanner/event_update_form.html | 2 + eventplanner/views.py | 6 +- website/static/css/contact.css | 3 +- website/templates/website/mainpage.html | 100 ++++++++++++++++++ website/views.py | 25 ++++- 6 files changed, 132 insertions(+), 4 deletions(-) diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index 4568dc0c6686f7cabef0d6d0404ab7dd46e21ad4..55198466e6a1304afb46ca2a6d1522922d917f2d 100644 GIT binary patch delta 481 zcmZqJ!Q8Ned4e?KvWYUzjLSAAEH!3l{K>%hlWFy4L!P&c9F6*nybO)%j*~ge;slKp z3{9*I4S-0`*xb_4)M#^o*+fx6<~s}mj6Dp@xlCJ_J(wpk-JC4oBL>u-!nnD|*OyUM zh1r+UA~h+c*t8(2+$gQ8uqdOvq$oGB$kMVPH$TbbnI`jQM+Y+mFmW*`i%MJaD$2^bX67k)=jTX=OsJl6(=PoXP8*(85>v_ zSeWSmon~rkX<%pxWEmM48tWQZ>Kd6E8CV&Bkf8;Hp1eETU1}Wz7jqdC^B3l=%y*g3 zF)w0%&OC#;o4JX(3}|;0GY=OJ8v`e!FfUVNYVqWzd>sV_1_pLUMnQ2FHU=Q2&cx)G zpPiVOr;w4DQ=*WUTC(|EzL^2D0F%IG_63|w@^Z|Mj9@1i8t59BA%f1-$kfo#TyC@e zqDzMSKr>kwau}Gcm}W3GG2~1R@$00>ZwIL^^oI{d+U+%s;a*Gxz79<($B#PM9i`8rH+BCto zQxiu6rrsi*q~M|;)Dv3i(n*{O3MzumP7XphvGnNRT6plL_y7I>|F^zN>$}vufSVg5 zS8;Ru?n|?u0We^%W0Cod8r_7q&^FqaP)(K@p?yaYy0Bf7yV8jl?TvE=`wkj*f$HoX zP0=&_$|kYP9x|OB;a?hMPjQ=eXeSZ8hjF)3!7=&)WAl7r*`BR)+jrLHX8f8bYL9Bo zpw?>5EtgkU7f0fwYI;~%0@|Y`x zI;1!BlMZN$e$jJ!LLFL3*tbbZXHqbLn#wLmoiMKt^`!vutif0{^b)!s*6Uu-oM{jM zq!8nS(B`DE@worR0Lzg9xf8J91up-0STwmvd}QPCt
diff --git a/eventplanner/views.py b/eventplanner/views.py index 8b3c1a7..b45c417 100644 --- a/eventplanner/views.py +++ b/eventplanner/views.py @@ -111,6 +111,7 @@ def deleteEvent( request, pk ): from django.views.generic.edit import UpdateView, CreateView +from location_field.widgets import LocationWidget class EventForm( ModelForm ): def __init__(self, *args, **kwargs): @@ -121,10 +122,11 @@ class EventForm( ModelForm ): class Meta: model = Event - fields= ['title', 'type', 'date','time', 'meeting_time', 'location', 'desc', ] + fields= [ 'type', 'title', 'date','time', 'meeting_time', 'location', 'map_location', 'desc', ] widgets = { - 'location': TextInput(), + 'location' : TextInput(), + 'map_location' : LocationWidget(), } diff --git a/website/static/css/contact.css b/website/static/css/contact.css index 4dae99b..fa082e3 100644 --- a/website/static/css/contact.css +++ b/website/static/css/contact.css @@ -89,7 +89,7 @@ box-shadow: 0 0 7px 0 rgba(26, 26, 26, 0.4); padding: 33px 0 33px; background: white; - top: 41%; + top: 70%; border-radius: 4px; } #contact .map .box_wrapp .box_cont{ @@ -166,6 +166,7 @@ box-shadow: none; border-radius: 3px; margin: 0 auto; + margin-top: 20px; display: block; width: 56%; -webkit-transition: background linear .2s, box-shadow linear .2s; diff --git a/website/templates/website/mainpage.html b/website/templates/website/mainpage.html index 533da2b..ea346eb 100644 --- a/website/templates/website/mainpage.html +++ b/website/templates/website/mainpage.html @@ -41,6 +41,7 @@ } + {% endaddtoblock %} @@ -74,6 +75,7 @@ {% addtoblock "css" strip %}{% endaddtoblock %} {% addtoblock "css" strip %}{% endaddtoblock %} + {% addtoblock "css" strip %}{% endaddtoblock %} {% if event %} @@ -159,5 +161,103 @@
{% endif %} + + + + {% addtoblock "js" %} + + + + {% if hasNextConcertInfo %} + + {% endif %} + + {% endaddtoblock %} + + + + {% addtoblock "css" %} + + {% endaddtoblock %} + + {% if hasNextConcertInfo %} +
+
+ +
+
+
+
+
+
Fahrt zum Konzert:
+
+ Nächstes Konzert ist in {{nextConcert.location}} am {{nextConcert.date}} um {{nextConcert.time | time:"H:i" }}
+ {% if nextConcert.meeting_time %} Treffpunkt ist um {{ nextConcert.meeting_time | time:"H:i" }}
{% endif %} + + + + +
Fahrzeit:
Strecke:
+ Schliessen +
+
+
+ +
+
+ {% endif %} + + + + {% endblock %} diff --git a/website/views.py b/website/views.py index 308ee6d..75df1e9 100644 --- a/website/views.py +++ b/website/views.py @@ -11,6 +11,7 @@ from django.contrib.auth.decorators import login_required from eventplanner.models import Event, EventParticipation +from musicians.models import Musician from datetime import datetime @@ -34,7 +35,29 @@ def home_view(request): context['participation'] = part[0].status else: context['hasParticipationSetForAllEvents'] = True - + + + + nextConcerts = Event.objects.filter( date__gte = datetime.now(), type = 'Conc' ).order_by('date')[:1] + if len( nextConcerts) > 0 : + nextConcert = nextConcerts[0] + + routeInfo = dict() + + user = Musician.objects.get( user = request.user ); + routeInfo['origin'] = user.street + ", " + str( user.zip_code ) + " " + user.city + + if nextConcert.map_location: + # map_location has format "lat,longitute,zoomlevel" + routeInfo['destination'] = ",".join( nextConcert.map_location.split(",")[:2] ) + else: + routeInfo['destination'] = nextConcert.location + + context['routeInfo'] = routeInfo + context['nextConcert'] = nextConcert + context['hasNextConcertInfo'] = True + else: + context['hasNextConcertInfo'] = False return render( request, 'website/mainpage.html', context )