Exemplo n.º 1
0
def edit_attraction(request, event_id, attraction_id):
    attraction = get_object_or_404(Attraction, pk=attraction_id)
    if request.method == "POST":
        form = AddAttractionForm(request.POST, instance=attraction)
        if form.is_valid():
            attraction = form.save()
            messages.success(request,
                             _('Attraction has been changed successfully.'))
            return http.HttpResponseRedirect(reverse(
                'events.views.attraction_details',
                args=(attraction.event.id, attraction.id,)))
    else:
        form = AddAttractionForm(instance=attraction)
    return render_to_response("events/attraction_edit.html",
                              {"form": form,
                               "attraction": attraction},
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def add_attraction(request, event_id):
    event = get_object_or_404(Event, pk=event_id)
    if request.method == 'POST':
        form = AddAttractionForm(request.POST)
        if form.is_valid():
            attraction = form.save(commit=False)
            attraction.event = event
            attraction.save()
            form.save()
            assign_perm('events.change_attraction', request.user, attraction)
            assign_perm('events.delete_attraction', request.user, attraction)
            messages.success(request,
                             _('Attraction has been added successfully.'))
            return http.HttpResponseRedirect(
                reverse('events.views.attraction_details',
                        args=(attraction.id, )))
    else:
        form = AddAttractionForm()
    return render_to_response("events/attraction_add.html", {"form": form},
                              context_instance=RequestContext(request))
Exemplo n.º 3
0
def edit_attraction(request, event_id, attraction_id):
    attraction = get_object_or_404(Attraction, pk=attraction_id)
    if request.method == "POST":
        form = AddAttractionForm(request.POST, instance=attraction)
        if form.is_valid():
            attraction = form.save()
            messages.success(request,
                             _('Attraction has been changed successfully.'))
            return http.HttpResponseRedirect(
                reverse('events.views.attraction_details',
                        args=(
                            attraction.event.id,
                            attraction.id,
                        )))
    else:
        form = AddAttractionForm(instance=attraction)
    return render_to_response("events/attraction_edit.html", {
        "form": form,
        "attraction": attraction
    },
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def add_attraction(request, event_id):
    event = get_object_or_404(Event, pk=event_id)
    if request.method == 'POST':
        form = AddAttractionForm(request.POST)
        if form.is_valid():
            attraction = form.save(commit=False)
            attraction.event = event
            attraction.save()
            form.save()
            assign_perm('events.change_attraction', request.user, attraction)
            assign_perm('events.delete_attraction', request.user, attraction)
            messages.success(request,
                             _('Attraction has been added successfully.'))
            return http.HttpResponseRedirect(reverse(
                'events.views.attraction_details',
                args=(attraction.id,)))
    else:
        form = AddAttractionForm()
    return render_to_response("events/attraction_add.html",
                              {"form": form},
                              context_instance=RequestContext(request))