Beispiel #1
0
def edit_trip(request, trip_id):
    user = request.user
    if request.method == "POST":
        trip_form = TripForm(request.POST)
        if trip_form.is_valid():
            trip = get_object_or_404(Trip, id=trip_id)
            trip.trip_name = trip_form.cleaned_data['trip_name']
            trip.trip_location = trip_form.cleaned_data['trip_location']
            trip.trip_description = trip_form.cleaned_data['trip_desc']
            trip.start_date = trip_form.cleaned_data['trip_start_date']
            trip.end_date = trip_form.cleaned_data['trip_end_date']
            trip.user = user
            trip.save()
    return HttpResponseRedirect(reverse('dashboard', kwargs={"trip_id": trip.id}))
Beispiel #2
0
def add_trip(request):
    user = request.user
    if request.method == "POST":
        trip_form = TripForm(request.POST)
        if trip_form.is_valid():
            trip = Trip()
            trip.trip_name = trip_form.cleaned_data['trip_name']
            trip.trip_location = trip_form.cleaned_data['trip_location']
            trip.trip_description = trip_form.cleaned_data['trip_desc']
            trip.start_date = trip_form.cleaned_data['trip_start_date']
            trip.end_date = trip_form.cleaned_data['trip_end_date']
            trip.total_expenses = 0
            trip.user = user
            trip.save()
    return HttpResponseRedirect(reverse('dashboard', kwargs={"trip_id": trip.id}))