コード例 #1
0
    def post(self):
        user_id = self.request.get('user_id')
        user = User.get_by_auth_id('%s|%s' % (self.module, user_id))
        if user:

            Unique.delete_multi(
                map(lambda s: 'User.auth_id:' + s, user.auth_ids))
            time.sleep(.25)

            user.key.delete()
            AppEventData(event=user_id,
                         event_type='user',
                         transaction='DEL',
                         user=self.user.email).put()
            data_cache.set('events', None)
            data_cache.set('%s-users-tuple' % self.module, None)
            time.sleep(.25)
            return self.render_response('manage_users.html',
                                        success=True,
                                        message='User %s succesfully deleted' %
                                        user_id,
                                        form=forms.AddUserForm(),
                                        users=self.get_users())

        self.redirect('/admin/manage_users')
コード例 #2
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')
コード例 #3
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
コード例 #4
0
 def post(self):
     #attempt build or a db_client before generating tasks, redirect if authorization does not exists
     conference_data = self.get_conference_data()
     try:
         client = DropboxClient(conference_data.dbox_access_token, "en_US", rest_client=None)
     except:
         conference_data.dbox_update = False
         data_cache.set('%s-conference_data'% self.module, None)
         conference_data.put()
         return self.render_response('utilities.html', 
                                     failed = True,
                                     message = 'Invalid DropBox authorization, please authorize again')
     sessions = self.get_sessions()
     for session in sessions:
         if session.blob_store_key != None:
             params = {  'session_key':session.key(), 
                         'conf_key':self.get_conference_data().key(),
                         'blob_key':session.blob_store_key.key()}
             taskqueue.add(url='/utilities/update_dropbox/',
                             method='POST',
                             params=params, 
                             target='db-upload')
             logging.info('taskqueue created')
         else: logging.error('Session did not post %s'% sesssion.name)
     return self.render_response('utilities.html', 
                                 success = True, 
                                 message = "Dropbox upload in progress...", 
                                 user_id = None)
コード例 #5
0
 def post(self):
     sessions = self.get_sessions()
     for session in sessions:
         session.uploaded_to_dbox = False
         session.put()
     data_cache.set('%s-sessions'% self.module, None)
     
     time.sleep(.25)
     return self.render_response('utilities.html', success = True, message = "SessionData DB Reset" )
     '''user_id = data_cache.get('user_id')
コード例 #6
0
 def post(self):
     key = self.request.get('session_key')
     session = SessionData.get(key)
     if session:  #key = session.blob_store_key
         if session.blob_store_key:
             session.blob_store_key.delete()
         AppEventData(event=session.name,
                      event_type='session',
                      transaction='DEL',
                      user=self.user.email).put()
         data_cache.set('events', None)
         session.delete()
         time.sleep(.25)
     self.redirect('/admin/manage_sessions')
コード例 #7
0
 def post(self):
     form = forms.AddUserForm(self.request.POST)
     users = self.get_users()
     if not form.validate():
         return self.render_response('manage_users.html',
                                     users=users,
                                     form=form)
     email = form.email.data.lower()
     firstname = form.firstname.data
     lastname = form.lastname.data
     email_user = form.email_user.data
     user_id = ('%s|%s' % (self.module, email))
     unique_properties = []
     created, user = self.user_model.create_user(user_id,
                                                 unique_properties,
                                                 email=email,
                                                 account_type='user',
                                                 firstname=firstname,
                                                 lastname=lastname,
                                                 verified=False)
     if created:
         AppEventData(event=email,
                      event_type='user',
                      transaction='CREATE',
                      user=email).put()
         data_cache.set('events', None)
         time.sleep(.25)
         data_cache.set('%s-users-tuple' % self.module, None)
         if email_user:
             url = self.uri_for('activate', _full=True)
             name = firstname + ' ' + lastname
             subject = email_messages.new_account[0]
             body = email_messages.new_account[1].format(url=url, name=name)
             mail.send_mail(sender=SENDER,
                            to=email,
                            subject=subject,
                            body=body)
         return self.render_response('manage_users.html',
                                     success=True,
                                     message='User added succesfully',
                                     users=users,
                                     form=form)
     elif not created:
         return self.render_response(
             'manage_users.html',
             failed=True,
             message='Duplicate user, please confirm email address',
             users=users,
             form=form)
コード例 #8
0
 def get(self):
     conference_data = self.get_conference_data()
     access_token = conference_data.dbox_access_token
     #access_token = data_cache.get('access_token')
     if access_token:
         try:
             client = DropboxClient(access_token,
                                    locale='en_US',
                                    rest_client=None)
             client.disable_access_token()
             conference_data.dbox_access_token = None
             data_cache.set('%s-conference_data' % self.module, None)
             conference_data.put()
         except:
             return self.render_response('utilities.html')
     return self.render_response('utilities.html',
                                 access_token=access_token)
コード例 #9
0
 def post(self):
     conference_data = self.get_conference_data()
     form = forms.ConferenceForm(self.request.POST, obj=conference_data)
     if not form.validate():
         return self.render_response(
             'edit_conference.html',
             form=form,
             failed=True,
             message="Form failed to validate with errors %s" % form.errors)
     form.populate_obj(conference_data)
     conference_data.start_date = parse('%s' % form.start.data).date()
     conference_data.end_date = parse('%s' % form.end.data).date()
     #TODO: compare values, make sure they are in chronological order.
     conference_data.save()
     data_cache.set('%s-conference_data' % self.module, None)
     time.sleep(.25)
     return self.redirect('/admin/conference_data')
コード例 #10
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')
コード例 #11
0
 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
コード例 #12
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)
コード例 #13
0
    def get(self):
        session = self.session
        params = self.request.params
        #logging.error('Params %s' % params)
        redirect = self.uri_for('auth-finish', _full=True)
        try:
            access_token, user_id, url_state = \
                    get_dropbox_auth_flow(session, redirect).finish(params)
            client = DropboxClient(access_token,
                                   locale='en_US',
                                   rest_client=None)
            conference_data = self.get_conference_data()
            conference_data.dbox_access_token = access_token
            data_cache.set('%s-conference_data' % self.module, None)
            conference_data.put()

            return self.render_response('utilities.html',
                                        access_token=access_token)
        except DropboxOAuth2Flow.BadRequestException, e:
            http_status(400)
コード例 #14
0
 def get(self):
     user_events = data_cache.get('%s-user_events' % self.module)
     if user_events == None:
         user_events = db.GqlQuery(
             "SELECT * FROM AppEventData WHERE event_type = 'user' and module = '%s' ORDER BY time_stamp DESC LIMIT 50"
             % self.module)
         logging.info('AppEventData DB Query')
         data_cache.set('%s-user_events' % self.module, user_events)
     session_events = data_cache.get('%s-session_events' % self.module)
     if session_events == None:
         session_events = db.GqlQuery(
             "SELECT * FROM AppEventData WHERE event_type = 'session' and module = '%s' ORDER BY time_stamp DESC LIMIT 50"
             % self.module)
         logging.info('AppEventData DB Query')
         data_cache.set('%s-session_events' % self.module, session_events)
     file_events = data_cache.get('%s-file_events' % self.module)
     if file_events == None:
         file_events = db.GqlQuery(
             "SELECT * FROM AppEventData WHERE event_type = 'file' and module = '%s' ORDER BY time_stamp DESC LIMIT 50"
             % self.module)
         logging.info('AppEventData DB Query')
         data_cache.set('%s-file_events' % self.module, file_events)
     self.render_response('logs.html',
                          user_events=user_events,
                          session_events=session_events,
                          file_events=file_events)
コード例 #15
0
    def post(self):
        key = self.request.get('blob_key')
        email_user = self.request.get('email_user')
        session_data_info = blobstore.BlobInfo.get(key)

        session_data_file = session_data_info.open()

        file_csv = csv.reader(session_data_file)
        check_csv(file_csv)

        for row in file_csv:
            firstname = row[0]
            lastname = row[1]
            email = row[2].lower()
            name = row[3]
            room = row[4]
            user_id = ('%s|%s' % (self.module, email))
            unique_properties = []
            created, user = self.user_model.create_user(user_id,
                                                        unique_properties,
                                                        email=email,
                                                        account_type='user',
                                                        firstname=firstname,
                                                        lastname=lastname,
                                                        verified=False)
            if created:
                AppEventData(event=email,
                             event_type='user',
                             transaction='CREATE',
                             user=self.user.email).put()
                data_cache.set('events', None)
            if created and email_user == 'on':

                url = self.uri_for('activate', _full=True)
                #name = firstname+' '+lastname
                #params = {'category':'new_account', 'email':email, 'name':name, 'url':url}
                #taskqueue.add(url='/send_emails',params=params, target='email-users')
                #url = self.uri_for('activate', _full=True)
                name = firstname + ' ' + lastname
                subject = email_messages.new_account[0]
                body = email_messages.new_account[1].format(url=url, name=name)
                mail.send_mail(sender=SENDER,
                               to=email,
                               subject=subject,
                               body=body)

            session = SessionData(firstname=firstname,
                                  lastname=lastname,
                                  user_id=email,
                                  name=name,
                                  room=room)
            AppEventData(event=name,
                         event_type='session',
                         transaction='CREATE',
                         user=self.user.email).put()
            data_cache.set('events', None)
            session.put()
            data_cache.set('sessions', None)

        time.sleep(.25)
        session_data_info.delete()
        self.redirect('/admin/manage_sessions')