Ejemplo n.º 1
0
def upload_photo(request):
    if request.method == 'POST':
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('photos.views.index'))
    else:
         form = PhotoForm()
    f = PhotoForm
    return render_to_response("photos/upload_photo.html",
                              {'form':form},
                              context_instance=RequestContext(request))    
Ejemplo n.º 2
0
def photos_new(request):
    rider = get_rider(request)
    if not rider:
        return redirect('/entourage/login')
    
    if request.method == 'POST':
        form = PhotoForm(request.POST)
        if form.is_valid():
            photo = form.save(commit=False)
            photo.added_by = rider
            photo.save()
            form.save_m2m()
            
            return redirect('/gallery/%s' % photo.id)
    else:
        form = PhotoForm()
    
    return render(request, 'gallery/new.html', {'form': form})