Exemple #1
0
def place_edit(request, city_slug, place_slug):
    place = get_object_or_404(Place,slug=place_slug,city__slug=city_slug)
    if request.method == 'POST':
        form = PlaceCityForm(request.POST, instance=place)
        if form.is_valid():
            place = form.save(commit=False)
            place.city = get_object_or_404(City,slug=city_slug)
            place.save()
            return HttpResponseRedirect(place.get_absolute_url())
    else:
        form = PlaceCityForm(instance=place)
    return render_to_response('places/city_place_form.html', {
        'form':form, 'place':place, 
    }, context_instance = RequestContext(request))
Exemple #2
0
def place_city_add(request, city_slug):
    if request.method == 'POST':
        form = PlaceCityForm(request.POST)
        if form.is_valid():
            place = form.save(commit=False)
            place.city = get_object_or_404(City,slug=city_slug)
            place.save()
            return HttpResponseRedirect(place.get_absolute_url())
    else:
        form = PlaceCityForm()
        city = City.objects.get(name__iexact=city_slug)
        ''' nuevo '''
        if ('x' in request.GET) and ('y' in request.GET):
          x = request.GET['x']
          y = request.GET['y']
          return render_to_response('places/city_place_form.html', {
              'form':form, 'city':city, 'x' : x, 'y' : y,
          }, context_instance = RequestContext(request))

    return render_to_response('places/city_place_form.html', {
        'form':form, 'city':city,
    }, context_instance = RequestContext(request))