Show previously used places on the map when selecting the venue for an event to allow reuse. Fixes #49
This commit is contained in:
parent
335943c0ff
commit
933d3285a8
5 changed files with 28 additions and 7 deletions
|
@ -87,7 +87,7 @@ class MemberAdmin(admin.ModelAdmin):
|
||||||
admin.site.register(Member, MemberAdmin)
|
admin.site.register(Member, MemberAdmin)
|
||||||
|
|
||||||
class AttendeeAdmin(admin.ModelAdmin):
|
class AttendeeAdmin(admin.ModelAdmin):
|
||||||
list_display = ('__str__', 'role', 'status')
|
list_display = ('__str__', 'role', 'status', 'last_reminded')
|
||||||
list_filter = ('role', 'status')
|
list_filter = ('role', 'status')
|
||||||
admin.site.register(Attendee, AttendeeAdmin)
|
admin.site.register(Attendee, AttendeeAdmin)
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<td width="120px"><b>Place:</b></td><td>
|
<td width="120px"><b>Place:</b></td><td>
|
||||||
{% if event.place %}
|
{% if event.place %}
|
||||||
<a class="" href="{% url 'show-place' event.place.id %}">{{ event.place.name }}</a>
|
<a class="" href="{% url 'show-place' event.place.id %}">{{ event.place.name }}</a>
|
||||||
|
{% if can_edit_event %}<a href="{% url 'add-place' event.id %}" class="btn btn-secondary btn-sm">Change</a>{% endif %}
|
||||||
{% elif can_edit_event %}
|
{% elif can_edit_event %}
|
||||||
<a class="" href="{% url 'add-place' event.id %}">No place selected yet.</a>
|
<a class="" href="{% url 'add-place' event.id %}">No place selected yet.</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<h2>Choose your meeting place</h2>
|
<h2>Choose your meeting place</h2>
|
||||||
<form action="{% url "add-place" event.id %}" method="post">
|
<form action="{% url "add-place" event.id %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<input type="hidden" id="id_id" name="id" value="" />
|
||||||
{% include "events/place_form.html" %}
|
{% include "events/place_form.html" %}
|
||||||
<div class="fluid-layout" id="place-map"></div>
|
<div class="fluid-layout" id="place-map"></div>
|
||||||
<br />
|
<br />
|
||||||
|
@ -46,8 +47,8 @@
|
||||||
markers: [],
|
markers: [],
|
||||||
html_addr: null,
|
html_addr: null,
|
||||||
mapOptions: {
|
mapOptions: {
|
||||||
zoom: 4,
|
zoom: 12,
|
||||||
center: {lat: 51.8211, lng: 5.591},
|
center: {lat: {{event.team.city.latitude}}, lng: {{event.team.city.longitude}}},
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||||
mapTypeControl: false
|
mapTypeControl: false
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@
|
||||||
name = this.long_name
|
name = this.long_name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (name != "") {
|
if (name != null && name != "") {
|
||||||
$("#id_name").val(name);
|
$("#id_name").val(name);
|
||||||
}
|
}
|
||||||
$.getJSON("/api/find_city/?country="+country+"&spr="+spr+"&city="+city,
|
$.getJSON("/api/find_city/?country="+country+"&spr="+spr+"&city="+city,
|
||||||
|
@ -93,7 +94,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.html_lng && options.html_lat) {
|
if (options.html_lng && options.html_lat) {
|
||||||
if (location.lat() && location.lng()) {
|
if (location.lat() != null && location.lng() != null) {
|
||||||
options.html_lat.val(location.lat());
|
options.html_lat.val(location.lat());
|
||||||
options.html_lng.val(location.lng());
|
options.html_lng.val(location.lng());
|
||||||
if (options.html_tz && options.html_country && options.html_continent) {
|
if (options.html_tz && options.html_country && options.html_continent) {
|
||||||
|
@ -191,6 +192,23 @@
|
||||||
location = new google.maps.LatLng(options.html_lat.val(), options.html_lng.val());
|
location = new google.maps.LatLng(options.html_lat.val(), options.html_lng.val());
|
||||||
setMarker(map, location);
|
setMarker(map, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.getJSON("/api/places/", function(data) {
|
||||||
|
for (let place of data) {
|
||||||
|
var position = new google.maps.LatLng(place['latitude'], place['longitude'])
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
position: position,
|
||||||
|
label: place['name'],
|
||||||
|
map: map,
|
||||||
|
});
|
||||||
|
google.maps.event.addListener(marker, 'click',function(event) {
|
||||||
|
$("#id_id").val(place['id']);
|
||||||
|
$("#id_name").val(place['name']);
|
||||||
|
showPositionHTML(this.position);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="fluid-container">
|
<div class="fluid-container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md">
|
<div class="col-md-9">
|
||||||
<h2>{{ place.name }}
|
<h2>{{ place.name }}
|
||||||
{% if can_edit_place %}
|
{% if can_edit_place %}
|
||||||
<a href="{% url 'edit-place' place.id %}" class="btn btn-secondary btn-sm">Edit Place</a>
|
<a href="{% url 'edit-place' place.id %}" class="btn btn-secondary btn-sm">Edit Place</a>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
height="400"
|
height="400"
|
||||||
frameborder="0" style="border:0"
|
frameborder="0" style="border:0"
|
||||||
src="https://www.google.com/maps/embed/v1/place?key={{ settings.GOOGLE_MAPS_API_KEY }}
|
src="https://www.google.com/maps/embed/v1/place?key={{ settings.GOOGLE_MAPS_API_KEY }}
|
||||||
&q={{place.name}},{{place.city}}" allowfullscreen>
|
&q={{place.name}},{{place.city}}" allowfullscreen>
|
||||||
</iframe>
|
</iframe>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -142,6 +142,8 @@ def add_place_to_event(request, event_id):
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = NewPlaceForm(request.POST)
|
form = NewPlaceForm(request.POST)
|
||||||
if form.is_valid:
|
if form.is_valid:
|
||||||
|
if request.POST.get('id', None):
|
||||||
|
form.instance.id = request.POST.get('id')
|
||||||
new_place = form.save()
|
new_place = form.save()
|
||||||
event.place = new_place
|
event.place = new_place
|
||||||
event.save()
|
event.save()
|
||||||
|
|
Loading…
Reference in a new issue