Exemple #1
0
    def get(self, app_id=None):
        user_info = models.User.get_by_id(long(self.user_id))
        app = models.App.get_by_id(long(app_id))

        # get our gist's filenames
        files = github.get_gist_filenames(app.gist_id)
        app_manifest = github.get_gist_manifest(app.gist_id)

        if app.owner == user_info.key:
            # update existing app with current manifest
            app.name = app_manifest['name']
            app.command = app_manifest['command']
            app.description = app_manifest['description']
            app.thumb_url = app_manifest['thumb_url']
            app.public = app_manifest['public']
            app.github_author = app_manifest['github_author']

            # write out our new app data
            app.put()

            # loop through files in gist and clear cache
            for afile in files:
                github.flush_raw_gist_content(app.gist_id, afile)

            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'

        params = {'app_response': response}
        return self.render_template('app/app_response.html', **params)
Exemple #2
0
    def get(self, app_id = None):
        user_info = models.User.get_by_id(long(self.user_id))
        app = models.App.get_by_id(long(app_id))

        # get our gist's filenames
        files = github.get_gist_filenames(app.gist_id)
        app_manifest = github.get_gist_manifest(app.gist_id)

        if app.owner == user_info.key:
            # update existing app with current manifest
            app.name = app_manifest['name']
            app.command = app_manifest['command']
            app.description = app_manifest['description']
            app.thumb_url = app_manifest['thumb_url']
            app.public = app_manifest['public']
            app.github_author = app_manifest['github_author']
            
            # write out our new app data
            app.put()

            # loop through files in gist and clear cache
            for afile in files:
                github.flush_raw_gist_content(app.gist_id, afile)
        
            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'
        
        params = {'app_response': response}
        return self.render_template('app/app_response.html', **params)
Exemple #3
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else:
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(
                user_info.key, 'github')
            apps = github.get_user_gists(social_user.uid,
                                         social_user.access_token)

            # update with the apps we get back from github
            for app in apps:
                app2 = models.App.get_by_user_and_gist_id(
                    user_info.key, app['gist_id'])

                if app2:
                    # update existing app with new data
                    app2.name = app['name']
                    app2.command = app['command']
                    app2.description = app['description']
                    app2.thumb_url = app['thumb_url']
                    app2.gist_id = app['gist_id']
                    app2.public = app['public']
                else:
                    # we have a new app on our hands - insert
                    app2 = models.App(
                        name=app['name'],
                        command=app['command'],
                        description=app['description'],
                        thumb_url=app['thumb_url'],
                        gist_id=app['gist_id'],
                        owner=user_info.key,
                        author=user_info.key,
                        github_author=app['github_author'],
                        public=app['public'],
                    )

                # update
                app2.put()

                # flush memcache copies just in case we had them
                # get our gist's filenames
                files = github.get_gist_filenames(app['gist_id'])

                for afile in files:
                    github.flush_raw_gist_content(app2.gist_id, afile)

            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return
Exemple #4
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else: 
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(user_info.key, 'github')
            apps = github.get_user_gists(social_user.uid, social_user.access_token)

            # update with the apps we get back from github
            for app in apps:
                app2 = models.App.get_by_user_and_gist_id(user_info.key, app['gist_id'])

                if app2:
                    # update existing app with new data
                    app2.name = app['name']
                    app2.command = app['command']
                    app2.description = app['description']
                    app2.thumb_url = app['thumb_url']
                    app2.gist_id = app['gist_id']
                    app2.public = app['public']
                else:
                    # we have a new app on our hands - insert
                    app2 = models.App(
                        name = app['name'],
                        command = app['command'],
                        description = app['description'],
                        thumb_url = app['thumb_url'],
                        gist_id = app['gist_id'],
                        owner = user_info.key,
                        author = user_info.key,
                        github_author = app['github_author'],
                        public = app['public'],
                    )
                
                # update
                app2.put()

                # flush memcache copies just in case we had them
                # get our gist's filenames
                files = github.get_gist_filenames(app['gist_id'])
                
                for afile in files:
                    github.flush_raw_gist_content(app2.gist_id, afile)
               
            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return