Exemplo n.º 1
0
def waypoint_new(request, pk):
    o = get_object_or_404(Object, pk=pk)
    if request.method == "POST":
        w = WaypointForm(request.POST)
        if w.is_valid():
            w = w.save(commit=False)
            w.owner = request.user
            w.published_date = timezone.now()
            w.object = o
            w.save()
            return render(request, 'object/view.html', {'object': o})
    else:
        w = WaypointForm()
    return render(request, 'waypoint/edit.html', {'waypoint': w})
Exemplo n.º 2
0
def waypoint_edit(request, pk, wpk):
    o = get_object_or_404(Object, pk=pk)
    w = get_object_or_404(Waypoint, pk=wpk)
    if not (request.user.has_perm('waypoint.changeown_waypoint')
            and w.owner == request.user
            ) and not request.user.has_perm('waypoint.change_waypoint'):
        return redirect(reverse_lazy('login'))
    if request.method == "POST":
        w = WaypointForm(request.POST, instance=w)
        if w.is_valid():
            w = w.save(commit=False)
            w.owner = request.user
            w.published_date = timezone.now()
            w.save()
            return render(request, 'object/view.html', {'object': o})
    else:
        w = WaypointForm(instance=w)
    return render(request, 'waypoint/edit.html', {'waypoint': w})
Exemplo n.º 3
0
def waypoint_edit(request, pk, wpk):
    o = get_object_or_404(Object, pk=pk)
    w = get_object_or_404(Waypoint, pk=wpk)
    if not (request.user.has_perm('waypoint.changeown_waypoint') and w.owner == request.user) and not request.user.has_perm('waypoint.change_waypoint'):
        return redirect(reverse_lazy('login'))
    if request.method == "POST":
        w = WaypointForm(request.POST, instance=w)
        if w.is_valid():
            w = w.save(commit=False)
            w.owner = request.user
            w.published_date = timezone.now()
            w.save()
            return render(request, 'object/view.html', {'object': o})
    else:
        w = WaypointForm(instance=w)
    return render(request, 'waypoint/edit.html', {'waypoint': w})
Exemplo n.º 4
0
def waypoint_new(request, pk):
    o = get_object_or_404(Object, pk=pk)
    if request.method == "POST":
        w = WaypointForm(request.POST)
        if w.is_valid():
            w = w.save(commit=False)
            w.owner = request.user
            w.published_date = timezone.now()
            w.object = o
            w.save()
            return render(request, 'object/view.html', {'object': o})
    else:
        w = WaypointForm()
    return render(request, 'waypoint/edit.html', {'waypoint': w})