def new_flight(request, page): if not request.POST: url = logbook_url(request.display_user, page) return HttpResponseRedirect(url) profile, c = Profile.objects.get_or_create(user=request.display_user) plane_widget = proper_plane_widget(profile) flight = Flight(user=request.display_user) form = forms.PopupFlightForm(request.POST, plane_widget=plane_widget, user=request.display_user, instance=flight, prefix="new") if form.is_valid() and request.display_user.username != 'ALL': form.save() from backup.models import edit_logbook edit_logbook.send(sender=request.display_user) url = logbook_url(request.display_user, page) return HttpResponseRedirect(url) return logbook(request, form=form, fail="new")
def new_flight(request, page): if not request.POST: url = logbook_url(request.display_user, page) return HttpResponseRedirect(url) profile,c = Profile.objects.get_or_create(user=request.display_user) plane_widget = proper_plane_widget(profile) flight = Flight(user=request.display_user) form = forms.PopupFlightForm(request.POST, plane_widget=plane_widget, user=request.display_user, instance=flight, prefix="new") if form.is_valid() and request.display_user.username != 'ALL': form.save() from backup.models import edit_logbook edit_logbook.send(sender=request.display_user) url = logbook_url(request.display_user, page) return HttpResponseRedirect(url) return logbook(request, form=form, fail="new")
def delete_flight(request, page): url = logbook_url(request.display_user, page) if not request.POST: return HttpResponseNotAllowed("method not allowed") if request.display_user.username != 'ALL': flight_id = request.POST['id'] Flight(pk=flight_id, user=request.display_user).delete() from backup.models import edit_logbook edit_logbook.send(sender=request.display_user, page=page) return HttpResponseRedirect(url)