diff --git a/get_together/templates/get_together/events/show_series.html b/get_together/templates/get_together/events/show_series.html index 43862ee..69c3f5a 100644 --- a/get_together/templates/get_together/events/show_series.html +++ b/get_together/templates/get_together/events/show_series.html @@ -64,9 +64,9 @@ Place: {% if series.place %} {{ series.place.name }} - {% if can_edit_event %}Change{% endif %} + {% if can_edit_event %}Change{% endif %} {% elif can_edit_event %} - No place selected yet. + No place selected yet. {% else %} No place selected yet. {% endif %} diff --git a/get_together/templates/get_together/places/add_place_to_series.html b/get_together/templates/get_together/places/add_place_to_series.html new file mode 100644 index 0000000..c6cc151 --- /dev/null +++ b/get_together/templates/get_together/places/add_place_to_series.html @@ -0,0 +1,231 @@ +{% extends "get_together/base.html" %} +{% load static %} +{% block content %} +
+
+
+ +

Choose your meeting place

+
+ {% csrf_token %} + + {% include "events/place_form.html" %} +
+
+ +
+ Add a Place later +
+
+
+
+{% endblock %} + +{% block javascript %} + + + + + +{% endblock %} diff --git a/get_together/templates/get_together/places/create_place.html b/get_together/templates/get_together/places/create_place.html index 6520f05..4262d4b 100644 --- a/get_together/templates/get_together/places/create_place.html +++ b/get_together/templates/get_together/places/create_place.html @@ -14,7 +14,7 @@
- Add a Place later + Add a Place later
diff --git a/get_together/urls.py b/get_together/urls.py index 9db7b63..13a1858 100644 --- a/get_together/urls.py +++ b/get_together/urls.py @@ -73,6 +73,7 @@ urlpatterns = [ path('events///', views.show_event, name='show-event'), path('series//+edit/', views.edit_series, name='edit-series'), path('series//+delete/', views.delete_series, name='delete-series'), + path('series//+add_place/', views.add_place_to_series, name='add-place-to-series'), path('series///', views.show_series, name='show-series'), path('org//', views.show_org, name='show-org'), diff --git a/get_together/views/events.py b/get_together/views/events.py index 55e42cc..8f0e31a 100644 --- a/get_together/views/events.py +++ b/get_together/views/events.py @@ -173,6 +173,9 @@ def add_place_to_event(request, event_id): new_place = form.save() event.place = new_place event.save() + if event.series is not None and event.series.place is None: + event.series.place = new_place; + event.series.save() return redirect('share-event', event.id) else: context = { @@ -183,6 +186,38 @@ def add_place_to_event(request, event_id): else: return redirect('home') +def add_place_to_series(request, series_id): + series = EventSeries.objects.get(id=series_id) + if not request.user.profile.can_edit_series(series): + messages.add_message(request, messages.WARNING, message=_('You can not make changes to this event.')) + return redirect(series.get_absolute_url()) + + if request.method == 'GET': + form = NewPlaceForm() + + context = { + 'series': series, + 'place_form': form, + } + return render(request, 'get_together/places/add_place_to_series.html', context) + elif request.method == 'POST': + form = NewPlaceForm(request.POST) + if form.is_valid: + if request.POST.get('id', None): + form.instance.id = request.POST.get('id') + new_place = form.save() + series.place = new_place + series.save() + return redirect('show-series', series.id, series.slug) + else: + context = { + 'series': series, + 'place_form': form, + } + return render(request, 'get_together/places/add_place_to_series.html', context) + else: + return redirect('home') + def share_event(request, event_id): event = Event.objects.get(id=event_id) context = {