parent
49ba4e5223
commit
230f1e6a36
Binary file not shown.
|
@ -141,10 +141,10 @@ INSTALLED_APPS = (
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
# Uncomment the next line to enable admin documentation:
|
# Uncomment the next line to enable admin documentation:
|
||||||
'django.contrib.admindocs',
|
'django.contrib.admindocs',
|
||||||
|
'location_field',
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
'musicians',
|
'musicians',
|
||||||
'eventplanner',
|
'eventplanner',
|
||||||
'locpick',
|
|
||||||
'sekizai',
|
'sekizai',
|
||||||
'intern_area',
|
'intern_area',
|
||||||
'website',
|
'website',
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% if field.is_hidden %}
|
||||||
|
{{ field }}
|
||||||
|
{% else %}
|
||||||
|
<div class="control-group {% if field.errors %}error{% endif %}">
|
||||||
|
<label for="{{ field.auto_id }}" class="control-label">
|
||||||
|
{% if field.field.required %}<b>{% endif %}{{ field.label|safe }}{% if field.field.required %}*</b>{% endif %}
|
||||||
|
</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ field }}
|
||||||
|
{% if field.errors %}
|
||||||
|
<span class="help-inline">{% for error in field.errors %}{{ error }}<br/> {% endfor %}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if field.help_text%}
|
||||||
|
<p class="help-block">
|
||||||
|
{{ field.help_text|safe }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
|
@ -2,7 +2,7 @@ from django.conf.urls import patterns, include, url
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from musicians.views import MusicianList
|
from musicians.views import MusicianList, addressbook
|
||||||
from musicians.views import user_edit
|
from musicians.views import user_edit
|
||||||
|
|
||||||
import intern_area.views
|
import intern_area.views
|
||||||
|
@ -17,15 +17,17 @@ from django.conf.urls.static import static
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'$^', website.views.home_view),
|
url(r'$^', website.views.home_view ),
|
||||||
url(r'^events/', include( eventplanner.urls.urlpatterns) ),
|
url(r'^events/', include( eventplanner.urls.urlpatterns) ),
|
||||||
url(r'^admin/', include(admin.site.urls) ),
|
url(r'^admin/', include(admin.site.urls) ),
|
||||||
url(r'^admin/doc/', include('django.contrib.admindocs.urls') ),
|
url(r'^admin/doc/', include('django.contrib.admindocs.urls') ),
|
||||||
|
|
||||||
url(r'^musicians/$', MusicianList.as_view() ),
|
url(r'^musicians/$', MusicianList.as_view() ),
|
||||||
url(r'^musicians/(?P<username>[\w]+)$', user_edit ),
|
url(r'^musicians/(?P<username>[\w]+)$', user_edit ),
|
||||||
|
url(r'^addressbook/$', addressbook ),
|
||||||
url(r'^admin_area/$', intern_area.views.login_site ),
|
url(r'^admin_area/$', intern_area.views.login_site ),
|
||||||
url(r'^login/$', website.views.login_view),
|
url(r'^login/$', website.views.login_view),
|
||||||
url(r'^logout/$', website.views.logout_view),
|
url(r'^logout/$', website.views.logout_view),
|
||||||
url(r'^messages/$', messages.views.message_view ),
|
url(r'^messages/$', messages.views.message_view ),
|
||||||
|
url(r'^location_field/', include('location_field.urls')),
|
||||||
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
@ -4,6 +4,8 @@ from django.utils.translation import ugettext as _
|
||||||
from musicians.models import Musician
|
from musicians.models import Musician
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from location_field.models import PlainLocationField
|
||||||
|
|
||||||
|
|
||||||
class Event ( models.Model ):
|
class Event ( models.Model ):
|
||||||
|
|
||||||
|
@ -17,11 +19,14 @@ class Event ( models.Model ):
|
||||||
title = models.CharField( max_length=40, verbose_name = _("titel") )
|
title = models.CharField( max_length=40, verbose_name = _("titel") )
|
||||||
type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") )
|
type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") )
|
||||||
location = models.TextField( blank=False, verbose_name=_("location") )
|
location = models.TextField( blank=False, verbose_name=_("location") )
|
||||||
|
map_location = PlainLocationField( based_fields = [location], zoom=7 )
|
||||||
desc = models.TextField( blank=True, verbose_name=_("description"))
|
desc = models.TextField( blank=True, verbose_name=_("description"))
|
||||||
|
|
||||||
date = models.DateField( verbose_name= _("date") )
|
date = models.DateField( verbose_name= _("date") )
|
||||||
time = models.TimeField( null=True, blank=True, verbose_name = _("time") )
|
time = models.TimeField( null=True, blank=True, verbose_name = _("time") )
|
||||||
meeting_time = models.TimeField( null=True, blank=True, verbose_name = _("meeting_time") )
|
meeting_time = models.TimeField( null=True, blank=True, verbose_name = _("meeting_time") )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
participants = models.ManyToManyField( Musician, through='EventParticipation', verbose_name=_("participants") )
|
participants = models.ManyToManyField( Musician, through='EventParticipation', verbose_name=_("participants") )
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/bindWithDelay.js" type="text/javascript" ></script>{% endaddtoblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% addtoblock "js" %}
|
{% addtoblock "js" %}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
from django.forms import fields
|
||||||
|
from location_field.widgets import LocationWidget
|
||||||
|
|
||||||
|
|
||||||
|
class PlainLocationField(fields.CharField):
|
||||||
|
def __init__(self, based_fields=None, zoom=None, default=None,
|
||||||
|
*args, **kwargs):
|
||||||
|
kwargs['initial'] = default
|
||||||
|
|
||||||
|
self.widget = LocationWidget(based_fields=based_fields, zoom=zoom,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
|
dwargs = {
|
||||||
|
'required': True,
|
||||||
|
'label': None,
|
||||||
|
'initial': None,
|
||||||
|
'help_text': None,
|
||||||
|
'error_messages': None,
|
||||||
|
'show_hidden_initial': False,
|
||||||
|
}
|
||||||
|
|
||||||
|
for attr in dwargs:
|
||||||
|
if attr in kwargs:
|
||||||
|
dwargs[attr] = kwargs[attr]
|
||||||
|
|
||||||
|
super(PlainLocationField, self).__init__(*args, **dwargs)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
($ || django.jQuery)(function($){
|
||||||
|
function location_field_load(map, location_based, zoom)
|
||||||
|
{
|
||||||
|
var parent = map.parent().parent();
|
||||||
|
|
||||||
|
var location_map;
|
||||||
|
|
||||||
|
var location_coordinate = parent.find('input[type=text]');
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
var point = new google.maps.LatLng(49.340174,10.890595);
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
mapTypeId: google.maps.MapTypeId.HYBRID
|
||||||
|
};
|
||||||
|
|
||||||
|
location_map = new google.maps.Map(map[0], options);
|
||||||
|
|
||||||
|
var initial_position;
|
||||||
|
|
||||||
|
if (location_coordinate.val())
|
||||||
|
{
|
||||||
|
var l = location_coordinate.val().split(/,/);
|
||||||
|
|
||||||
|
if (l.length > 1)
|
||||||
|
{
|
||||||
|
initial_position = new google.maps.LatLng(l[0], l[1]);
|
||||||
|
location_map.setZoom( parseInt(l[2]) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
location_map.setZoom(zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function savePosition( p )
|
||||||
|
{
|
||||||
|
point = p;
|
||||||
|
location_coordinate.val(point.lat().toFixed(6) + "," + point.lng().toFixed(6) + "," + location_map.getZoom() );
|
||||||
|
}
|
||||||
|
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
map: location_map,
|
||||||
|
position: initial_position,
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
google.maps.event.addListener(marker, 'dragend', function(mouseEvent) {
|
||||||
|
savePosition(mouseEvent.latLng);
|
||||||
|
});
|
||||||
|
|
||||||
|
google.maps.event.addListener(location_map, 'click', function(mouseEvent){
|
||||||
|
marker.setPosition(mouseEvent.latLng);
|
||||||
|
savePosition(mouseEvent.latLng);
|
||||||
|
});
|
||||||
|
|
||||||
|
google.maps.event.addListener(location_map, 'zoom_changed', function(mouseEvent){
|
||||||
|
savePosition(point);
|
||||||
|
});
|
||||||
|
|
||||||
|
location_based.bindWithDelay("keypress", function() {
|
||||||
|
|
||||||
|
var lstr = [];
|
||||||
|
location_based.each(function(){
|
||||||
|
var b = $(this);
|
||||||
|
lstr.push(b.val())
|
||||||
|
});
|
||||||
|
|
||||||
|
geocode(lstr.join(','), function(l){
|
||||||
|
location_coordinate.val( l.lat()+','+l.lng() );
|
||||||
|
});
|
||||||
|
|
||||||
|
onLocationCoordinateChange();
|
||||||
|
}, 2000 );
|
||||||
|
|
||||||
|
|
||||||
|
function onLocationCoordinateChange()
|
||||||
|
{
|
||||||
|
var latlng = jQuery(this).val().split(/,/);
|
||||||
|
if (latlng.length < 2) return;
|
||||||
|
var latlng = new google.maps.LatLng(latlng[0], latlng[1]);
|
||||||
|
placeMarker( latlng );
|
||||||
|
location_map.setZoom( latlng[2] );
|
||||||
|
//geocode_reverse(latlng, function(l){
|
||||||
|
// location_coordinate.val(l.lat()+','+l.lng());
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
|
function placeMarker(location) {
|
||||||
|
marker.setPosition(location);
|
||||||
|
location_map.setCenter(location);
|
||||||
|
savePosition(location);
|
||||||
|
location_map.panTo(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
function geocode(address, cb) {
|
||||||
|
var result;
|
||||||
|
var geocoder = new google.maps.Geocoder();
|
||||||
|
if (geocoder) {
|
||||||
|
geocoder.geocode({"address": address}, function(results, status) {
|
||||||
|
if (status == google.maps.GeocoderStatus.OK) {
|
||||||
|
cb(results[0].geometry.location);
|
||||||
|
placeMarker(results[0].geometry.location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
function geocode_reverse(location, cb) {
|
||||||
|
var geocoder = new google.maps.Geocoder();
|
||||||
|
if (geocoder) {
|
||||||
|
geocoder.geocode({"latLng": location}, function(results, status) {
|
||||||
|
if (status == google.maps.GeocoderStatus.OK) {
|
||||||
|
cb(results[0].geometry.location);
|
||||||
|
placeMarker(results[0].geometry.location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
placeMarker(initial_position);
|
||||||
|
}
|
||||||
|
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('input[data-location-widget]').each(function(){
|
||||||
|
var $el = $(this);
|
||||||
|
|
||||||
|
var $map = $($el.attr('data-map')),
|
||||||
|
$based_fields = $($el.attr('data-based-fields')),
|
||||||
|
zoom = parseInt($el.attr('data-zoom'));
|
||||||
|
|
||||||
|
location_field_load($map, $based_fields, zoom);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,40 @@
|
||||||
|
from django.db.models import CharField
|
||||||
|
|
||||||
|
from location_field import forms
|
||||||
|
|
||||||
|
|
||||||
|
class BaseLocationField(object):
|
||||||
|
def __init__(self, based_fields=[], zoom=2, default=None, *args, **kwargs):
|
||||||
|
self._based_fields = based_fields
|
||||||
|
self._zoom = zoom
|
||||||
|
self._default = default
|
||||||
|
self.default = default
|
||||||
|
|
||||||
|
def formfield(self, **kwargs):
|
||||||
|
return super(BaseLocationField, self).formfield(
|
||||||
|
form_class=self.formfield_class,
|
||||||
|
based_fields=self._based_fields,
|
||||||
|
zoom=self._zoom,
|
||||||
|
default=self._default,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class PlainLocationField(BaseLocationField, CharField):
|
||||||
|
formfield_class = forms.PlainLocationField
|
||||||
|
|
||||||
|
def __init__(self, based_fields=None, zoom=None,
|
||||||
|
max_length=63, *args, **kwargs):
|
||||||
|
|
||||||
|
super(PlainLocationField, self).__init__(based_fields=based_fields,
|
||||||
|
zoom=zoom, *args, **kwargs)
|
||||||
|
|
||||||
|
CharField.__init__(self, max_length=max_length, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
# south compatibility
|
||||||
|
try:
|
||||||
|
from south.modelsinspector import add_introspection_rules
|
||||||
|
add_introspection_rules([], ["^location_field\.models\.LocationField"])
|
||||||
|
add_introspection_rules([], ["^django\.contrib\.gis"])
|
||||||
|
except:
|
||||||
|
pass
|
|
@ -0,0 +1,11 @@
|
||||||
|
from django.conf.urls.defaults import patterns
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
app_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
urlpatterns = patterns(
|
||||||
|
'',
|
||||||
|
(r'^media/(.*)$', 'django.views.static.serve', {
|
||||||
|
'document_root': '%s/media' % app_dir}),
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
# Create your views here.
|
|
@ -0,0 +1,54 @@
|
||||||
|
from django.forms import widgets
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
|
|
||||||
|
class LocationWidget(widgets.TextInput):
|
||||||
|
def __init__(self, attrs=None, based_fields=None, zoom=None, **kwargs):
|
||||||
|
self.based_fields = based_fields
|
||||||
|
self.zoom = zoom
|
||||||
|
super(LocationWidget, self).__init__(attrs)
|
||||||
|
|
||||||
|
def render(self, name, value, attrs=None):
|
||||||
|
if value is not None:
|
||||||
|
lat, lng, zoom = value.split(',')
|
||||||
|
|
||||||
|
value = '%s,%s,%d' % (
|
||||||
|
float(lat),
|
||||||
|
float(lng),
|
||||||
|
float(zoom)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
value = ''
|
||||||
|
|
||||||
|
if '-' not in name:
|
||||||
|
prefix = ''
|
||||||
|
else:
|
||||||
|
prefix = name[:name.rindex('-') + 1]
|
||||||
|
|
||||||
|
based_fields = ','.join(
|
||||||
|
map(lambda f: '#id_' + prefix + f.name, self.based_fields))
|
||||||
|
|
||||||
|
attrs = attrs or {}
|
||||||
|
attrs['data-location-widget'] = name
|
||||||
|
attrs['data-based-fields'] = based_fields
|
||||||
|
attrs['data-zoom'] = self.zoom
|
||||||
|
attrs['data-map'] = '#map_' + name
|
||||||
|
|
||||||
|
text_input = super(LocationWidget, self).render(name, value, attrs)
|
||||||
|
|
||||||
|
map_div = u'''
|
||||||
|
<div style="margin:4px 0 0 0">
|
||||||
|
<label></label>
|
||||||
|
<div id="map_%(name)s" style="width: 610px; height: 350px"></div>
|
||||||
|
</div>
|
||||||
|
'''
|
||||||
|
return mark_safe(text_input + map_div % {'name': name})
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
# Use schemaless URL so it works with both, http and https websites
|
||||||
|
js = (
|
||||||
|
'//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', # jquery
|
||||||
|
'//maps.google.com/maps/api/js?sensor=false&language=de',
|
||||||
|
'/static/js/bindWithDelay.js',
|
||||||
|
'/location_field/media/form.js',
|
||||||
|
)
|
|
@ -1,93 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
from django.template import loader
|
|
||||||
|
|
||||||
from locpick import settings
|
|
||||||
from locpick.widget import LocationPickerWidget
|
|
||||||
|
|
||||||
|
|
||||||
class LocationField(models.CharField):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
kwargs['max_length'] = 100
|
|
||||||
return super(LocationField, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def formfield(self, **kwargs):
|
|
||||||
kwargs['widget'] = LocationPickerWidget
|
|
||||||
return super(LocationField, self).formfield(**kwargs)
|
|
||||||
|
|
||||||
def contribute_to_class(self, cls, name):
|
|
||||||
super(LocationField, self).contribute_to_class(cls, name)
|
|
||||||
setattr(cls, self.name, LocationFieldDescriptor(self))
|
|
||||||
|
|
||||||
|
|
||||||
class LocationFieldDescriptor(object):
|
|
||||||
|
|
||||||
def __init__(self, field):
|
|
||||||
self.field = field
|
|
||||||
|
|
||||||
def __get__(self, instance=None, owner=None):
|
|
||||||
if instance is None:
|
|
||||||
raise AttributeError(
|
|
||||||
"The '%s' attribute can only be accessed from %s instances."
|
|
||||||
% (self.field.name, owner.__name__))
|
|
||||||
return Map(instance.__dict__[self.field.name])
|
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
|
||||||
instance.__dict__[self.field.name] = value
|
|
||||||
|
|
||||||
|
|
||||||
class Map(object):
|
|
||||||
|
|
||||||
def __init__(self, value):
|
|
||||||
self.value = value
|
|
||||||
self.position = 49.340119, 10.890325
|
|
||||||
self.center = 49.340119, 10.890325
|
|
||||||
self.zoom = 4
|
|
||||||
if value:
|
|
||||||
values = value.split(',')
|
|
||||||
self.zoom = int(values.pop())
|
|
||||||
values = [str(float(it)) for it in values]
|
|
||||||
self.position = values[0], values[1]
|
|
||||||
self.center = values[2], values[3]
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return str(self.value)
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.value)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return unicode(self)
|
|
||||||
|
|
||||||
def __nonzero__(self):
|
|
||||||
return bool(self.value)
|
|
||||||
|
|
||||||
def render_map(self, width=settings.DEFAULT_MAP_WIDTH, height=settings.DEFAULT_MAP_HEIGHT):
|
|
||||||
return loader.render_to_string(
|
|
||||||
'locpick/map.html',
|
|
||||||
{
|
|
||||||
'id': id(self),
|
|
||||||
'map': self,
|
|
||||||
'width': width,
|
|
||||||
'height': height,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def external_url(self):
|
|
||||||
return "http://maps.google.com/?ll=%s,%s&z=%s&q=%s,%s" % (
|
|
||||||
self.center[0],
|
|
||||||
self.center[1],
|
|
||||||
self.zoom,
|
|
||||||
self.position[0],
|
|
||||||
self.position[1],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
from south.modelsinspector import add_introspection_rules
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
add_introspection_rules([], [r"^locpick\.field\.LocationField"])
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_MAP_WIDTH = getattr(settings, 'LOCPICK_DEFAULT_MAP_WIDTH', 600)
|
|
||||||
DEFAULT_MAP_HEIGHT = getattr(settings, 'LOCPICK_DEFAULT_MAP_HEIGHT', 300)
|
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
//#google.load("maps", "2");
|
|
||||||
|
|
||||||
/*$(document).unload(function(){
|
|
||||||
GUnload();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$("input.location_picker").each(function (i) {
|
|
||||||
var geocoder = new google.maps.Geocoder();
|
|
||||||
var map = $('<div>');
|
|
||||||
var input = this;
|
|
||||||
map.addClass("location_picker_map");
|
|
||||||
map.attr('id', 'location_picker_map');
|
|
||||||
$(this).css('display','none');
|
|
||||||
var search_field = $('<input type=textbox style="margin-left: 10em; width: 20em">');
|
|
||||||
var search_button = $('<input type="button" value="Search">')
|
|
||||||
search_field.attr('id', 'location_picker_search')
|
|
||||||
$(this).parent().append(map);
|
|
||||||
$(this).parent().append($('<br>'));
|
|
||||||
$(this).parent().append(search_field);
|
|
||||||
$(this).parent().append(search_button);
|
|
||||||
|
|
||||||
|
|
||||||
if (this.value.split(',').length == 5) {
|
|
||||||
values = this.value.split(',');
|
|
||||||
var position = new google.maps.LatLng(values[0], values[1]);
|
|
||||||
var center = new google.maps.LatLng(values[2], values[3]);
|
|
||||||
var zoom = parseInt(values[4]);
|
|
||||||
} else {
|
|
||||||
var center = new google.maps.LatLng(49.340119,10.890325);
|
|
||||||
var position = new google.maps.LatLng(49.340119,10.890325);
|
|
||||||
var zoom = 17;
|
|
||||||
this.value = position.lat()
|
|
||||||
+ ',' + position.lng()
|
|
||||||
+ ',' + center.lat()
|
|
||||||
+ ',' + center.lng()
|
|
||||||
+ ',' + zoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
geocoder.geocode({'latLng': position}, function(results, status) {
|
|
||||||
if (status == google.maps.GeocoderStatus.OK) {
|
|
||||||
if (results[0]) {
|
|
||||||
document.getElementById('location_picker_search').value = results[0].formatted_address ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var myOptions = {
|
|
||||||
zoom: zoom,
|
|
||||||
center: center,
|
|
||||||
mapTypeId: google.maps.MapTypeId.HYBRID
|
|
||||||
};
|
|
||||||
var gmap = new google.maps.Map(document.getElementById("location_picker_map"), myOptions);
|
|
||||||
|
|
||||||
if (position != null) {
|
|
||||||
var marker = new google.maps.Marker({
|
|
||||||
position: position,
|
|
||||||
map: gmap,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var marker = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function geoCode(){
|
|
||||||
var address = document.getElementById("location_picker_search").value;
|
|
||||||
geocoder.geocode( { 'address': address}, function(results, status) {
|
|
||||||
if (status == google.maps.GeocoderStatus.OK) {
|
|
||||||
var latLon = results[0].geometry.location;
|
|
||||||
gmap.setCenter(latLon);
|
|
||||||
if (marker == null){
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
position: latLon,
|
|
||||||
map: gmap,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
marker.setPosition(latLon);
|
|
||||||
}
|
|
||||||
updateInput();
|
|
||||||
} else {
|
|
||||||
alert("Geocode was not successful for the following reason: " + status);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
search_button.click(function() {
|
|
||||||
result = geoCode();
|
|
||||||
});
|
|
||||||
search_field.bind('keydown', function(e) {
|
|
||||||
var code = (e.keyCode ? e.keyCode : e.which);
|
|
||||||
if (code == 13) { //Enter keycode
|
|
||||||
geoCode();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function updateInput(){
|
|
||||||
if (marker == null){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var pos = marker.getPosition();
|
|
||||||
input.value = pos.lat()
|
|
||||||
+ ',' + pos.lng()
|
|
||||||
+ ',' + gmap.getCenter().lat()
|
|
||||||
+ ',' + gmap.getCenter().lng()
|
|
||||||
+ ',' + gmap.getZoom();
|
|
||||||
}
|
|
||||||
google.maps.event.addListener(gmap, 'click', function(event) {
|
|
||||||
if (marker == null) {
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
position: event.latLng,
|
|
||||||
map: gmap,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
marker.setPosition(event.latLng);
|
|
||||||
}
|
|
||||||
updateInput();
|
|
||||||
});
|
|
||||||
|
|
||||||
google.maps.event.addListener(gmap, 'center_changed', function(event) {
|
|
||||||
updateInput();
|
|
||||||
});
|
|
||||||
google.maps.event.addListener(gmap, 'zoom_changed', function(event) {
|
|
||||||
updateInput();
|
|
||||||
});
|
|
||||||
|
|
||||||
function HomeControl(controlDiv, gmap) {
|
|
||||||
|
|
||||||
controlDiv.style.padding = '5px';
|
|
||||||
|
|
||||||
// Set CSS for the control border
|
|
||||||
var controlUI = document.createElement('DIV');
|
|
||||||
controlUI.style.backgroundColor = 'white';
|
|
||||||
controlUI.style.borderStyle = 'solid';
|
|
||||||
controlUI.style.borderWidth = '1px';
|
|
||||||
controlUI.style.cursor = 'pointer';
|
|
||||||
controlUI.style.textAlign = 'center';
|
|
||||||
controlUI.title = 'Click to remove the marker';
|
|
||||||
controlDiv.appendChild(controlUI);
|
|
||||||
|
|
||||||
// Set CSS for the control interior
|
|
||||||
var controlText = document.createElement('DIV');
|
|
||||||
controlText.style.fontFamily = 'sans-serif';
|
|
||||||
controlText.style.fontSize = '12px';
|
|
||||||
controlText.style.paddingLeft = '4px';
|
|
||||||
controlText.style.paddingRight = '4px';
|
|
||||||
controlText.innerHTML = 'Clear';
|
|
||||||
controlUI.appendChild(controlText);
|
|
||||||
|
|
||||||
// Setup the click event listeners: simply set the map to Chicago
|
|
||||||
google.maps.event.addDomListener(controlUI, 'click', function() {
|
|
||||||
if (marker != null){
|
|
||||||
marker.setMap(null);
|
|
||||||
marker = null;
|
|
||||||
input.value = '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var homeControlDiv = document.createElement('DIV');
|
|
||||||
var homeControl = new HomeControl(homeControlDiv, gmap);
|
|
||||||
|
|
||||||
homeControlDiv.index = 1;
|
|
||||||
gmap.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,7 +0,0 @@
|
||||||
.location_picker_map {
|
|
||||||
width: 600px;
|
|
||||||
height: 400px;
|
|
||||||
border: 1px solid black;
|
|
||||||
padding: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<div id='locpick_map_canvas_{{id}}' style="width:{{width}}px; height:{{height}}px">
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
( function() {
|
|
||||||
function initialize() {
|
|
||||||
var center = new google.maps.LatLng({{map.center.0}}, {{map.center.1}});
|
|
||||||
var position = new google.maps.LatLng({{map.position.0}}, {{map.position.1}});
|
|
||||||
var myOptions = {
|
|
||||||
zoom: {{map.zoom}},
|
|
||||||
center: center,
|
|
||||||
mapTypeId: google.maps.MapTypeId.HYBRID
|
|
||||||
};
|
|
||||||
var map = new google.maps.Map(document.getElementById("locpick_map_canvas_{{id}}"), myOptions);
|
|
||||||
var marker = new google.maps.Marker({
|
|
||||||
position: position,
|
|
||||||
map: map
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize();
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
|
|
@ -1,28 +0,0 @@
|
||||||
from django import template
|
|
||||||
|
|
||||||
from locpick import settings
|
|
||||||
|
|
||||||
|
|
||||||
register = template.Library()
|
|
||||||
|
|
||||||
|
|
||||||
class LocpickNode(template.Node):
|
|
||||||
def __init__(self, field, width=settings.DEFAULT_MAP_WIDTH, height=settings.DEFAULT_MAP_HEIGHT):
|
|
||||||
self.field_name = field
|
|
||||||
self.width = width
|
|
||||||
self.height = height
|
|
||||||
|
|
||||||
def render(self, context):
|
|
||||||
field = template.Variable(self.field_name).resolve(context)
|
|
||||||
return field.render_map(width=self.width, height=self.height)
|
|
||||||
|
|
||||||
|
|
||||||
@register.tag
|
|
||||||
def gmap(parser, token):
|
|
||||||
bits = token.split_contents()
|
|
||||||
if len(bits) == 2:
|
|
||||||
return LocpickNode(field=bits[1])
|
|
||||||
elif len(bits) == 4:
|
|
||||||
return LocpickNode(field=bits[1], width=bits[2], height=bits[3])
|
|
||||||
else:
|
|
||||||
raise template.TemplateSyntaxError('{% locpick instance.location_field %} or {% locpick instance.location_field WIDTH HEIGHT %}')
|
|
|
@ -1,33 +0,0 @@
|
||||||
from django import forms
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
|
||||||
if hasattr(settings, 'LOCPICK_STATIC_URL'):
|
|
||||||
STATIC_URL = settings.LOCPICK_STATIC_URL
|
|
||||||
else:
|
|
||||||
STATIC_URL = settings.STATIC_URL + 'locpick/'
|
|
||||||
|
|
||||||
|
|
||||||
class LocationPickerWidget(forms.TextInput):
|
|
||||||
class Media:
|
|
||||||
css = {
|
|
||||||
'all': (
|
|
||||||
STATIC_URL + 'location_picker.css',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
js = (
|
|
||||||
'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
|
|
||||||
'http://maps.google.com/maps/api/js?sensor=false',
|
|
||||||
STATIC_URL + 'jquery.location_picker.js',
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, language=None, attrs=None):
|
|
||||||
self.language = language or settings.LANGUAGE_CODE[:2]
|
|
||||||
super(LocationPickerWidget, self).__init__(attrs=attrs)
|
|
||||||
|
|
||||||
def render(self, name, value, attrs=None):
|
|
||||||
if None == attrs:
|
|
||||||
attrs = {}
|
|
||||||
attrs['class'] = 'location_picker'
|
|
||||||
return super(LocationPickerWidget, self).render(name, value, attrs)
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import os
|
||||||
INSTRUMENTS = (
|
INSTRUMENTS = (
|
||||||
('TR', _('Trumpet') ),
|
('TR', _('Trumpet') ),
|
||||||
('TRB', _('Trombone') ),
|
('TRB', _('Trombone') ),
|
||||||
('EUPH',_('Euphonium') ),
|
('HRN',_('Horn') ),
|
||||||
('TUBA',_('Tuba') )
|
('TUBA',_('Tuba') )
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,14 +16,20 @@ def musicianPictureName( musician, originalName ):
|
||||||
fileExtension = os.path.splitext(originalName)[1]
|
fileExtension = os.path.splitext(originalName)[1]
|
||||||
return "user_images/" + musician.user.username + fileExtension
|
return "user_images/" + musician.user.username + fileExtension
|
||||||
|
|
||||||
|
def musicianSmallPictureName( musician, originalName ):
|
||||||
|
fileExtension = os.path.splitext(originalName)[1]
|
||||||
|
return "user_images/" + musician.user.username + "_thumb" + fileExtension
|
||||||
|
|
||||||
|
|
||||||
class Musician( models.Model ):
|
class Musician( models.Model ):
|
||||||
# Link to user object, contains first name and last name
|
# Link to user object, contains first name and last name
|
||||||
user = models.OneToOneField( User, verbose_name=_("user") )
|
user = models.OneToOneField( User, verbose_name=_("user") )
|
||||||
|
|
||||||
# Properties
|
image = models.ImageField( upload_to = musicianPictureName, verbose_name=_("image") )
|
||||||
image = models.ImageField( upload_to = musicianPictureName, verbose_name=_("image") )
|
small_image = models.ImageField( upload_to = musicianSmallPictureName, verbose_name = _("circular thumbnail") )
|
||||||
|
|
||||||
|
|
||||||
|
# Properties
|
||||||
instrument = models.CharField( max_length=4, choices=INSTRUMENTS, blank=True, verbose_name=_("instrument") )
|
instrument = models.CharField( max_length=4, choices=INSTRUMENTS, blank=True, verbose_name=_("instrument") )
|
||||||
|
|
||||||
birthday = models.DateField( null=True, verbose_name=_("birthday") )
|
birthday = models.DateField( null=True, verbose_name=_("birthday") )
|
||||||
|
@ -36,7 +42,13 @@ class Musician( models.Model ):
|
||||||
phone_mobile = models.CharField( max_length=18, blank=True, verbose_name=_("phone_mobile") )
|
phone_mobile = models.CharField( max_length=18, blank=True, verbose_name=_("phone_mobile") )
|
||||||
phone_work = models.CharField( max_length=18, blank=True, verbose_name=_("phone_work") )
|
phone_work = models.CharField( max_length=18, blank=True, verbose_name=_("phone_work") )
|
||||||
|
|
||||||
|
@property
|
||||||
|
def isDeepBrass(self):
|
||||||
|
return self.instrument == 'TRB' or self.instrument == "EUPH" or self.instrument == "TUBA" or self.instrument == "HRN"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def isHighBrass(self):
|
||||||
|
return self.instrument == 'TR'
|
||||||
|
|
||||||
public_description = models.TextField( blank=True, verbose_name=_("public_description") )
|
public_description = models.TextField( blank=True, verbose_name=_("public_description") )
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
{% extends "website/base.html" %}
|
||||||
|
|
||||||
|
|
||||||
|
{% load sekizai_tags staticfiles %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block feature_slider %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block navbar_options %} navbar navbar-inverse navbar-static-top {% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
{% addtoblock "css" strip %}<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/portfolio.css" media="screen, projection">{% endaddtoblock %}
|
||||||
|
|
||||||
|
{% addtoblock "css" %}
|
||||||
|
<style>
|
||||||
|
.addressbook_entry {
|
||||||
|
box-shadow: 0px 0px 7px -1px rgb(214, 214, 214);
|
||||||
|
border: 2px solid rgb(217, 217, 217);
|
||||||
|
width: 350px !important;
|
||||||
|
float: left;
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addressbook_entry .name {
|
||||||
|
color: rgb(83, 83, 83);
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 18px;
|
||||||
|
margin: 0px 0px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addressbook_entry td {
|
||||||
|
padding-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addressbook_entry .picture {
|
||||||
|
max-width: 55px;
|
||||||
|
float: right;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
{% endaddtoblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/jquery.isotope.min.js"></script> {% endaddtoblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% addtoblock "js" %}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
|
||||||
|
var $container = $('#gallery_container'),
|
||||||
|
$filters = $("#filters a");
|
||||||
|
|
||||||
|
$container.imagesLoaded( function(){
|
||||||
|
$container.isotope({
|
||||||
|
itemSelector : '.photo',
|
||||||
|
masonry: {
|
||||||
|
columnWidth: 102
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// filter items when filter link is clicked
|
||||||
|
$filters.click(function() {
|
||||||
|
$filters.removeClass("active");
|
||||||
|
$(this).addClass("active");
|
||||||
|
var selector = $(this).data('filter');
|
||||||
|
$container.isotope({ filter: selector });
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endaddtoblock %}
|
||||||
|
|
||||||
|
|
||||||
|
<div id="portfolio">
|
||||||
|
<div class="container">
|
||||||
|
<div class="section_header">
|
||||||
|
<h3>Adressbuch</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="filters_container">
|
||||||
|
<ul id="filters">
|
||||||
|
<li><a href="#" data-filter="*" class="active">Alle</a></li>
|
||||||
|
<li class="separator">/</li>
|
||||||
|
<li><a href="#" data-filter=".unterstimme">Unterstimmen</a></li>
|
||||||
|
<li class="separator">/</li>
|
||||||
|
<li><a href="#" data-filter=".oberstimmen">Oberstimmen</a></li>
|
||||||
|
<li class="separator">/</li>
|
||||||
|
<li><a href="#" data-filter=".rest">Rest</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="gallery_container" >
|
||||||
|
|
||||||
|
{% for m in musicians %}
|
||||||
|
<div class="photo isotope-item addressbook_entry {% if m.isDeepBrass %} unterstimme {% elif m.isHighBrass %} oberstimme {% else %} rest {% endif %} ">
|
||||||
|
|
||||||
|
<div class="span1">
|
||||||
|
<img src="{{MEDIA_URL}}/user_images/{{m.user}}_circle.png" class="img-circle picture">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="name">
|
||||||
|
{{ m.user.first_name }} {{m.user.last_name }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{% if m.street %} <tr><td> Adresse </td><td>{{m.street}} </td>
|
||||||
|
<tr><td> </td><td>{{m.zip_code}} {{m.city}}</td>{% endif %}
|
||||||
|
{% if m.birthday %} <tr><td> Geburtstag: </td><td>{{m.birthday }} </td>{% endif %}
|
||||||
|
{% if m.phone_home %} <tr><td> Telefon (Home): </td><td>{{m.phone_home }} </td>{% endif %}
|
||||||
|
{% if m.phone_mobile %}<tr><td> Telefon (Mobil): </td><td>{{m.phone_mobile }} </td>{% endif %}
|
||||||
|
{% if m.phone_work %} <tr><td> Telefon (Arbeit): </td><td>{{m.phone_work }} </td>{% endif %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class MusicianList( ListView):
|
||||||
model = Musician
|
model = Musician
|
||||||
|
|
||||||
|
|
||||||
class UserEditForm(forms.ModelForm):
|
class UserEditForm( forms.ModelForm ):
|
||||||
|
|
||||||
email = forms.EmailField()
|
email = forms.EmailField()
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ class UserEditForm(forms.ModelForm):
|
||||||
model = Musician
|
model = Musician
|
||||||
exclude = [ 'user','image', 'instrument' ]
|
exclude = [ 'user','image', 'instrument' ]
|
||||||
#fields = '__all__'
|
#fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def user_edit( request, username ):
|
def user_edit( request, username ):
|
||||||
|
@ -66,4 +65,20 @@ class MusicianUpdate( UpdateView ):
|
||||||
model = Musician
|
model = Musician
|
||||||
#fields = []
|
#fields = []
|
||||||
template_name = "musicians/musician_edit.html"
|
template_name = "musicians/musician_edit.html"
|
||||||
success_url = '/books/'
|
success_url = '/books/'
|
||||||
|
|
||||||
|
|
||||||
|
def addressbook( request ):
|
||||||
|
context = dict()
|
||||||
|
context['musicians'] = Musician.objects.all()
|
||||||
|
|
||||||
|
return render( request, 'musicians/addressbook.html', context )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/jquery.countdown.min.js"></script> {% endaddtoblock %}
|
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/jquery.countdown.min.js"></script> {% endaddtoblock %}
|
||||||
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/theme.js"></script> {% endaddtoblock %}
|
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/theme.js"></script> {% endaddtoblock %}
|
||||||
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/index-slider.js" type="text/javascript" ></script>{% endaddtoblock %}
|
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/index-slider.js" type="text/javascript" ></script>{% endaddtoblock %}
|
||||||
|
{% addtoblock "js" strip %} <script src="{{STATIC_URL}}/js/bindWithDelay.js" type="text/javascript" ></script>{% endaddtoblock %}
|
||||||
|
|
||||||
{% addtoblock "js" %}
|
{% addtoblock "js" %}
|
||||||
|
|
||||||
|
|
|
@ -75,87 +75,89 @@
|
||||||
{% addtoblock "css" strip %}<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/lib/animate.css" media="screen, projection">{% endaddtoblock %}
|
{% addtoblock "css" strip %}<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/lib/animate.css" media="screen, projection">{% endaddtoblock %}
|
||||||
{% addtoblock "css" strip %}<link rel="stylesheet" href="{{STATIC_URL}}/css/coming-soon.css" type="text/css" media="screen" />{% endaddtoblock %}
|
{% addtoblock "css" strip %}<link rel="stylesheet" href="{{STATIC_URL}}/css/coming-soon.css" type="text/css" media="screen" />{% endaddtoblock %}
|
||||||
|
|
||||||
|
{% if event %}
|
||||||
|
|
||||||
|
{% addtoblock "js" %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function callback(event) {
|
||||||
|
$this = $(this);
|
||||||
|
$this.find('span#'+event.type).html(event.value);
|
||||||
|
switch(event.type) {
|
||||||
|
case "seconds":
|
||||||
|
case "minutes":
|
||||||
|
case "hours":
|
||||||
|
case "days":
|
||||||
|
case "weeks":
|
||||||
|
case "daysLeft":
|
||||||
|
case "finished":
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('div#clock').countdown(new Date().valueOf() + {{epoch}} , callback);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endaddtoblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div id="coming_soon">
|
||||||
|
<div class="head">
|
||||||
|
<div class="container">
|
||||||
|
<div class="span6 text">
|
||||||
|
<h4>Der nächste Termin:</h4>
|
||||||
|
<p>
|
||||||
|
{{event.title}} ist am {{event.date}} um {{event.displaytime | time:"H:i" }} in {{event.location}}
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
{% 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 %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="span6 count" id="clock">
|
||||||
|
<div class="box last">
|
||||||
|
<div class="circle">
|
||||||
|
<span id="seconds"></span>
|
||||||
|
</div>
|
||||||
|
<p>Sekunden</p>
|
||||||
|
</div>
|
||||||
|
<div class="box">
|
||||||
|
<div class="circle">
|
||||||
|
<span id="minutes"></span>
|
||||||
|
</div>
|
||||||
|
<p>Minuten</p>
|
||||||
|
</div>
|
||||||
|
<div class="box">
|
||||||
|
<div class="circle">
|
||||||
|
<span id="hours"></span>
|
||||||
|
</div>
|
||||||
|
<p>Stunden</p>
|
||||||
|
</div>
|
||||||
|
<div class="box">
|
||||||
|
<div class="circle">
|
||||||
|
<span id="days"></span>
|
||||||
|
</div>
|
||||||
|
<p>Tage</p>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="box">
|
||||||
|
<div class="circle">
|
||||||
|
<span id="weeks"></span>
|
||||||
|
</div>
|
||||||
|
<p>Weeks</p>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% addtoblock "js" %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function () {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function callback(event) {
|
|
||||||
$this = $(this);
|
|
||||||
$this.find('span#'+event.type).html(event.value);
|
|
||||||
switch(event.type) {
|
|
||||||
case "seconds":
|
|
||||||
case "minutes":
|
|
||||||
case "hours":
|
|
||||||
case "days":
|
|
||||||
case "weeks":
|
|
||||||
case "daysLeft":
|
|
||||||
case "finished":
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('div#clock').countdown(new Date().valueOf() + {{epoch}} , callback);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endaddtoblock %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="coming_soon">
|
|
||||||
<div class="head">
|
|
||||||
<div class="container">
|
|
||||||
<div class="span6 text">
|
|
||||||
<h4>Der nächste Termin:</h4>
|
|
||||||
<p>
|
|
||||||
{{event.title}} ist am {{event.date}} um {{event.displaytime | time:"H:i" }} in {{event.location}}
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
{% 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 %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="span6 count" id="clock">
|
|
||||||
<div class="box last">
|
|
||||||
<div class="circle">
|
|
||||||
<span id="seconds"></span>
|
|
||||||
</div>
|
|
||||||
<p>Sekunden</p>
|
|
||||||
</div>
|
|
||||||
<div class="box">
|
|
||||||
<div class="circle">
|
|
||||||
<span id="minutes"></span>
|
|
||||||
</div>
|
|
||||||
<p>Minuten</p>
|
|
||||||
</div>
|
|
||||||
<div class="box">
|
|
||||||
<div class="circle">
|
|
||||||
<span id="hours"></span>
|
|
||||||
</div>
|
|
||||||
<p>Stunden</p>
|
|
||||||
</div>
|
|
||||||
<div class="box">
|
|
||||||
<div class="circle">
|
|
||||||
<span id="days"></span>
|
|
||||||
</div>
|
|
||||||
<p>Tage</p>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="box">
|
|
||||||
<div class="circle">
|
|
||||||
<span id="weeks"></span>
|
|
||||||
</div>
|
|
||||||
<p>Weeks</p>
|
|
||||||
</div> -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -7,26 +7,35 @@ from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from django.utils import simplejson
|
from django.utils import simplejson
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
|
||||||
from eventplanner.models import Event, EventParticipation
|
from eventplanner.models import Event, EventParticipation
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@login_required
|
||||||
def home_view(request):
|
def home_view(request):
|
||||||
events = Event.objects.filter( date__gte = datetime.now() ).order_by('date')[:1]
|
|
||||||
context = dict()
|
context = dict()
|
||||||
|
|
||||||
|
events = Event.objects.filter( date__gte = datetime.now() ).order_by('date')[:1]
|
||||||
part = EventParticipation.objects.filter( musician__user = request.user ).filter( event = events[0] )
|
if ( len(events) > 0 ):
|
||||||
|
print "len(events): " + str( len(events ))
|
||||||
eventTime = datetime( events[0].date.year, events[0].date.month, events[0].date.day,
|
nextEvent = events[0]
|
||||||
events[0].displaytime.hour, events[0].displaytime.minute )
|
part = EventParticipation.objects.filter( musician__user = request.user ).filter( event = nextEvent )
|
||||||
|
|
||||||
context['hasParticipationSetForAllEvents'] = EventParticipation.hasUserSetParticipationForAllEvents( request.user)
|
eventTime = datetime( events[0].date.year, events[0].date.month, events[0].date.day,
|
||||||
context['event'] = events[0]
|
events[0].displaytime.hour, events[0].displaytime.minute )
|
||||||
context['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
|
||||||
context['participation'] = part[0].status
|
context['hasParticipationSetForAllEvents'] = EventParticipation.hasUserSetParticipationForAllEvents( request.user)
|
||||||
|
context['event'] = events[0]
|
||||||
|
|
||||||
|
context['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
||||||
|
context['participation'] = part[0].status
|
||||||
|
else:
|
||||||
|
context['hasParticipationSetForAllEvents'] = True
|
||||||
|
|
||||||
|
|
||||||
return render( request, 'website/mainpage.html', context )
|
return render( request, 'website/mainpage.html', context )
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +57,8 @@ def login_view(request):
|
||||||
if not request.POST.get('remember', None):
|
if not request.POST.get('remember', None):
|
||||||
request.session.set_expiry( 0 )
|
request.session.set_expiry( 0 )
|
||||||
login(request, user)
|
login(request, user)
|
||||||
result['redirect'] = reverse( home_view )
|
#result['redirect'] = reverse( home_view )
|
||||||
|
result['redirect'] = "/"
|
||||||
else:
|
else:
|
||||||
result['err'] = "Dein Account wurde deaktiviert."
|
result['err'] = "Dein Account wurde deaktiviert."
|
||||||
# Return a 'disabled account' error message
|
# Return a 'disabled account' error message
|
||||||
|
|
Loading…
Reference in New Issue