Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
695:2d35e5f97a99 | 696:b2a8fde3173a |
---|---|
1 """Views for the user_photos application.""" | 1 """Views for the user_photos application.""" |
2 from django.conf import settings | 2 from django.conf import settings |
3 from django.contrib.auth.decorators import login_required | 3 from django.contrib.auth.decorators import login_required |
4 from django.shortcuts import render | 4 from django.shortcuts import render, redirect |
5 | 5 |
6 from user_photos.forms import UploadForm | 6 from user_photos.forms import UploadForm |
7 | 7 |
8 | 8 |
9 @login_required | 9 @login_required |
17 pass off the processing to a celery task | 17 pass off the processing to a celery task |
18 ajax version of this view | 18 ajax version of this view |
19 | 19 |
20 """ | 20 """ |
21 form = None | 21 form = None |
22 uploads_enabled = settings.USER_PHOTO_ENABLED | 22 uploads_enabled = settings.USER_PHOTOS_ENABLED |
23 | 23 |
24 if uploads_enabled: | 24 if uploads_enabled: |
25 if request.method == 'POST': | 25 if request.method == 'POST': |
26 form = UploadForm(request.POST, request.FILES) | 26 form = UploadForm(request.POST, request.FILES, user=request.user) |
27 if form.is_valid(): | 27 if form.is_valid(): |
28 #TODO | 28 photo = form.save() |
29 print "**************", request.FILES['image_file'] | 29 return redirect(photo) |
30 pass | |
31 else: | 30 else: |
32 form = UploadForm() | 31 form = UploadForm(user=request.user) |
33 | 32 |
34 return render(request, 'user_photos/upload_form.html', { | 33 return render(request, 'user_photos/upload_form.html', { |
35 'enabled': uploads_enabled, | 34 'enabled': uploads_enabled, |
36 'form': form, | 35 'form': form, |
37 }, | 36 }, |