def find_lectures(request): print 'webapp.views.find_lectures' client = request.session['dropbox_client'] lectures = list() try: metadata = client.metadata('/') if metadata.get('contents') is None: print 'webapp.views.find_lectures - No Content' return None for f in metadata['contents']: if f['is_dir'] == True: if not Lecture.objects.filter(user = request.user, name = f['path']).exists(): l = Lecture(user = request.user, name = f['path'], date = dateparse.parse_datetime(f['modified']), done = False) l.save() lectures.append(l) else: print 'webapp.views.find_lectures - lecture already exists' pprint.pprint(lectures) return lectures except Exception as e: print 'Exception: webapp.views.find_lectures - ' + str(e) return None
def add_lecture(request): print 'webapp.views.add_lecture' if request.method == 'POST': lecture = Lecture( user = request.user, name = '/Lecture_' + request.POST.get('name'), done = False) lecture.save() return render_to_response('capture.html', RequestContext(request, locals())) else: return redirect('/')