def add_place_to_series(request, series_id): series = get_object_or_404(EventSeries, 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 new_event_add_place(request, event_id): event = get_object_or_404(Event, id=event_id) if not request.user.profile.can_edit_event(event): messages.add_message(request, messages.WARNING, message=_('You can not make changes to this event.')) return redirect(event.get_absolute_url()) if request.method == 'GET': form = NewPlaceForm() context = { 'event': event, 'place_form': form, } return render(request, 'get_together/new_event/add_place.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() 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('new-event-add-details', event.id) else: context = { 'event': event, 'place_form': form, } return render(request, 'get_together/new_event/add_place.html', context) else: return redirect('home')
def add_place_to_event(request, event_id): event = get_object_or_404(Event, id=event_id) if not request.user.profile.can_edit_event(event): messages.add_message( request, messages.WARNING, message=_("You can not make changes to this event."), ) return redirect(event.get_absolute_url()) if request.method == "GET": form = NewPlaceForm() context = {"event": event, "place_form": form} return render(request, "get_together/places/create_place.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() 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(event.get_absolute_url()) else: context = {"event": event, "place_form": form} return render(request, "get_together/places/create_place.html", context) else: return redirect("home")
def add_place_to_event(request, event_id): event = Event.objects.get(id=event_id) if not request.user.profile.can_edit_event(event): messages.add_message( request, messages.WARNING, message=_('You can not make changes to this event.')) return redirect(event.get_absolute_url()) if request.method == 'GET': form = NewPlaceForm() context = { 'event': event, 'place_form': form, } return render(request, 'get_together/places/create_place.html', context) elif request.method == 'POST': form = NewPlaceForm(request.POST) if form.is_valid: new_place = form.save() event.place = new_place event.save() return redirect('share-event', event.id) else: context = { 'event': event, 'place_form': form, } return render(request, 'get_together/places/create_place.html', context) else: return redirect('home')
def add_place_to_series(request, series_id): series = get_object_or_404(EventSeries, 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 create_place(request): if request.method == "GET": form = NewPlaceForm() context = {"place_form": form} return render(request, "get_together/places/create_place.html", context) elif request.method == "POST": form = NewPlaceForm(request.POST) if form.is_valid(): new_place = form.save() return redirect("places") else: context = {"place_form": form} return render(request, "get_together/places/create_place.html", context) else: return redirect("home")
def create_place(request): if request.method == 'GET': form = NewPlaceForm() context = { 'place_form': form, } return render(request, 'get_together/places/create_place.html', context) elif request.method == 'POST': form = NewPlaceForm(request.POST) if form.is_valid(): new_place = form.save() return redirect('places') else: context = { 'place_form': form, } return render(request, 'get_together/places/create_place.html', context) else: return redirect('home')