Mercurial > public > sg101
diff user_photos/views.py @ 696:b2a8fde3173a
Got the image resizing and uploading working. It needs a lot of work though.
This commit is just to capture something that works.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 08 Sep 2013 19:06:54 -0500 |
parents | 2d35e5f97a99 |
children | 809d27b385f2 |
line wrap: on
line diff
--- a/user_photos/views.py Sat Sep 07 20:50:46 2013 -0500 +++ b/user_photos/views.py Sun Sep 08 19:06:54 2013 -0500 @@ -1,7 +1,7 @@ """Views for the user_photos application.""" from django.conf import settings from django.contrib.auth.decorators import login_required -from django.shortcuts import render +from django.shortcuts import render, redirect from user_photos.forms import UploadForm @@ -19,17 +19,16 @@ """ form = None - uploads_enabled = settings.USER_PHOTO_ENABLED + uploads_enabled = settings.USER_PHOTOS_ENABLED if uploads_enabled: if request.method == 'POST': - form = UploadForm(request.POST, request.FILES) + form = UploadForm(request.POST, request.FILES, user=request.user) if form.is_valid(): - #TODO - print "**************", request.FILES['image_file'] - pass + photo = form.save() + return redirect(photo) else: - form = UploadForm() + form = UploadForm(user=request.user) return render(request, 'user_photos/upload_form.html', { 'enabled': uploads_enabled,