def get(self, class_id): cls = Class.get_by_id(int(class_id)) if not cls: self.abort(404) upload_to = blobstore.create_upload_url('/addmaterial') return self.render('app/class_detail.html', cls=cls, upload_to=upload_to)
def post(self): upload_files = self.get_uploads('mfile') title = self.request.get('mtitle') class_id = self.request.get('class_id') cls = Class.get_by_id(int(class_id)) for afile in upload_files: cls.add_material(title, afile.key()) return redirect('/class/' + str(cls.key.id()) + '#support-tab')
def upload_video(self): upload_files = self.get_uploads('video_upload') title = self.request.get('video_title') class_id = self.request.get('class_id') import pdb;pdb.set_trace() cls = Class.get_by_id(int(class_id)) print 'Video Uploaded - ' + str(upload_files) return redirect('/class/' + str(cls.key.id()) + '#video-tab')
def add_resource(self): cls = Class.get_by_id(int(self.request.get('class_id'))) if not cls: self.abort(404) title = self.request.get('rtitle') url = self.request.get('rurl') cls.add_resource(title, url) deferred.defer(notify_followers_new_content, cls.subject, _queue='notify') return redirect('/class/' + str(cls.key.id()) + '#additional-tab')
def delete(self, class_id): cls = Class.get_by_id(int(class_id)) if cls: cls.key.delete() return redirect_to('classes_by_subject', subject_id=cls.subject.id())