def add_image(request): print 'webapp.views.add_image' # pprint.pprint(request) if request.method == 'POST': try: lecture = Lecture.objects.get(user = request.user, id = request.POST.get('lecture')) name = str(timezone.now()) i = InputImage( user = request.user, path = name, lecture = lecture, url = request.POST.get('file')) i.save() pprint.pprint(i) upld_image(request, i) # translate(i) except Exception as e: print 'Exception: webapp.views.add_image - ' + str(e) # return render_to_response('capture.html', RequestContext(request, locals())) # else: return redirect('/home/')
def find_images(request, lecture): print 'webapp.views.find_images' client = request.session['dropbox_client'] try: metadata = client.metadata(lecture.name) if metadata.get('contents') is None: print 'webapp.views.find_images - No Content' return None for f in metadata['contents']: if 'image' in f['mime_type']: if not InputImage.objects.filter(user = request.user, path = f['path']).exists(): m = client.media(f['path']) i = InputImage( user = request.user, path = f['path'], lecture = lecture, date = dateparse.parse_datetime(f['modified']), url = m['url']) i.save() translate(i) else: print 'webapp.views.find_images - image already exists' except Exception as e: print 'Exception: webapp.views.find_images - ' + str(e) return None