Esempio n. 1
0
 def post(self, resource):
     key = self.request.get('session_key')
     resource = str(urllib.unquote(resource))
     blob_info = blobstore.BlobInfo.get(resource)
     session = SessionData.get(key)
     blob_info.delete()
     AppEventData(event=session.filename,
                  event_type='file',
                  transaction='DEL',
                  user=self.user.email).put()
     session.blob_store_key = None
     session.filename = None
     session.uploaded_to_dbox = False
     params = {
         'session_key': key,
         'conf_key': self.get_conference_data().key(),
         'db_path': session.dbox_path
     }
     taskqueue.add(url='/utilities/delete_dropbox/',
                   method='POST',
                   params=params,
                   target='db-upload')
     data_cache.set('file', None)
     session.put()
     time.sleep(.25)
     self.redirect('/admin')
Esempio n. 2
0
 def post(self):
     key = self.request.get('key')
     session = SessionData.get(key)
     form = forms.SessionForm(self.request.POST, obj=session)
     form.users.choices = self.get_users_tuple()
     if not form.validate():
         logging.error(
             "Session Form Validation Errors in UpdateSessionHandler %s" %
             form.errors)
         return self.render_response('edit_session.html',
                                     failed=True,
                                     message='Invalid form submission',
                                     form=form,
                                     key=key)
     form.populate_obj(session)
     session.date = str(parse('%s' % form.date.data).date())
     session.time = str(parse('%s' %
                              form.time.data).time().isoformat())[0:5]
     session.dotw = parse('%s' % form.date.data).date().strftime("%A")
     session.user_id = form.users.data
     session.save()
     data_cache.set('%s-sessions' % self.module, None)
     time.sleep(.25)
     form = forms.SessionForm()
     form.users.choices = self.get_users_tuple()
     return self
 def post(self):
     key = self.request.get('session_key')
     c_key = self.request.get('conf_key')
     blob_info = self.request.get('blob_info')
     session = SessionData.get(key)
     conference_data = ConferenceData.get(c_key)
     if session.uploaded_to_dbox: 
         logging.info('Session | %s | already exists'% session.name)
         return
     if conference_data.dbox_access_token:
         access_token = conference_data.dbox_access_token
     else:
         logging.error('FAILED access_token does not exist') 
         #params = {'message':'Authorization token is either revoked or does not exist'}
         #taskqueue.add(url='/utilities/update_dropbox/',
         #                    method='GET',
         #                    params=params, 
         #                    target='%s'% conference_data.module)
         return None
     try:
         client = DropboxClient(access_token, "en_US", rest_client=None)
         logging.info('SUCCESS dbox_client created %s' % client)
     except:
         logging.error('FAILED dbox_client was not created')
         return None
     f = session.blob_store_key.open()
     size = session.blob_store_key.size
     uploader = client.get_chunked_uploader(f, size)
     while uploader.offset < size:
         try:
             upload = uploader.upload_chunked()
         except:
             logging.error('FAILED upload of file %s'% f)
             params = {'session_key':key, 
                     'conf_key': c_key, 
                     'blob_key':blob_info}
             taskqueue.add(url='/utilities/update_dropbox/',
                             method='POST',
                             params=params, 
                             target='db-upload')
     filename = session.filename
     if (conference_data.name and session.room and session.presenter[1] and filename):
         response = uploader.finish('/%s/%s/%s/%s'% (conference_data.name, session.room, session.presenter[1], filename), overwrite = False) #folder structure /conf_name/room/date/lastname/filename
     elif filename:
         response = uploader.finish('/default/%s'% filename, overwrite = False)
     else:
         logging.error('FAILED problem naming file, file skipped')
         f.close()
         return None
     session.uploaded_to_dbox = True
     session.dbox_path = response['path']
     session.dbox_size = response['size']
     session.put()
     f.close()
     return
Esempio n. 4
0
 def post(self):
     upload_files = self.get_uploads('file')
     if upload_files:
         key = self.request.get('session_key')
         session = SessionData.get(key)
         blob_info = upload_files[0]
         session.blob_store_key = blob_info.key()
         session.filename = blob_info.filename
         session.uploaded_to_dbox = False
         data_cache.set('%s-sessions' % self.module, None)
         session.put()
         time.sleep(.25)
         if self.upload_to_db():
             params = {'session_key': key, 'blob_key': blob_info}
     taskqueue.add(url='/utilities/update_dropbox/',
                   method='POST',
                   params=params,
                   target='db-upload')
     return self.redirect('/default')
 def post(self):
     session = SessionData.get(self.request.get('session_key'))
     conference_data = ConferenceData.get(self.request.get('conf_key'))
     db_path = self.request.get('db_path')
     try:
         client = DropboxClient(conference_data.dbox_access_token, "en_US", rest_client=None)
         logging.info('DB client created %s' % client)
     except:
         logging.info("DB Client was not created, access token is %s"% conference_data.dbox_access_token)
         return None
     try:
         client.file_delete(session.dbox_path)
         logging.info('File %s was deleted' % session.dbox_path)
     except:
         logging.error('File %s not deleted'% session.dbox_path)
         return
     session.dbox_path = None
     data_cache.set('%s-sessions'% session.module, None)
     return
Esempio n. 6
0
    def post(self):
        upload_files = self.get_uploads('file')
        form = forms.SessionForm()
        form.users.choices = self.get_users_tuple()
        sessions = self.get_sessions()
        if not upload_files:
            return self.render_response(
                'manage_sessions.html',
                failed=True,
                message="Presentation upload failed, please try again",
                sessions=sessions,
                form=form)
        key = self.request.get('session_key')
        session = SessionData.get(key)
        blob_info = upload_files[0]
        logging.info(
            "blob key %s | %s | %s | blob_info, blob_info.key, blob_info.key()"
            % (blob_info, blob_info.key, blob_info.key()))
        session.blob_store_key = blob_info.key()
        session.uploaded_to_dbox = False
        session.filename = blob_info.filename
        data_cache.set('%s-sessions' % self.module, None)
        session.put()
        time.sleep(.25)
        logging.info("session.blob_store_key is %s" % session.blob_store_key)

        if self.upload_to_db():
            params = {
                'session_key': key,
                'conf_key': self.get_conference_data().key(),
                'blob_key': blob_info.key()
            }
            taskqueue.add(url='/utilities/update_dropbox/',
                          method='POST',
                          params=params,
                          target='db-upload')
        return self.render_response(
            'manage_sessions.html',
            success=True,
            message='Presentation for | %s | upload successful' % session.name,
            sessions=sessions,
            form=form)
Esempio n. 7
0
    def post(self):
        key = self.request.get('session_key')
        session = SessionData.get(key)
        user = User.query(User.email == session.user_id).get()
        form = forms.SessionForm(obj=session)
        form.users.choices = self.get_users_tuple()
        form.date.data = parse('%s' % session.date).date()
        form.time.data = parse('%s' % session.time).time()

        if user:
            form.users.choices.insert(
                0, (session.user_id, user.lastname + ', ' + user.firstname))
            return self.render_response("edit_session.html",
                                        form=form,
                                        key=key)
        else:
            return self.render_response(
                "edit_session.html",
                failed=True,
                message=
                'That presenter no longer exists in the database, please choose a new presenter',
                form=form,
                key=key)