Beispiel #1
0
 def get(self):
     user_id = tornado.escape.xhtml_escape(self.current_user)
     template = 'afterlogintemplate.html'
     topic = logic.get_current_topic(
         tornado.escape.xhtml_escape(self.current_user))
     location = logic.get_current_location(
         tornado.escape.xhtml_escape(self.current_user))
     relevant_locations = logic.get_relevant_locations()
     if topic is None:
         self.redirect("/topicinfo")
     variables = {
         'title':
         "Conversations",
         'alerts':
         logic.get_topic_list(user_id),
         'type':
         "conversation",
         'username':
         str(tornado.escape.xhtml_escape(self.get_current_username())),
         "docs":
         apiv12.getConversations(topic['topic_id'], "day", 0),
         'topic':
         topic,
         'location':
         location,
         'relevant_locations':
         relevant_locations
     }
     content = self.render_template(template, variables)
     self.write(content)
Beispiel #2
0
    def get(self):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()
        events = logic.get_events(topic['topic_id'], "date", location, 0)

        if topic is None:
            self.redirect("/topicinfo")
        variables = {
            'title':
            "Events",
            'alerts':
            logic.get_topic_list(user_id),
            'type':
            "events",
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'cursor':
            events['next_cursor'],
            "document":
            events,
            'topic':
            topic,
            'location':
            location,
            'relevant_locations':
            relevant_locations
        }
        content = self.render_template(template, variables)
        self.write(content)
Beispiel #3
0
    def get(self, argument=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()
        if topic is None:
            self.redirect("/topicinfo")

        variables = {
            'title':
            "Bookmark",
            'feeds':
            logic.get_bookmarks(user_id),
            'alertid':
            topic['topic_id'],
            'alerts':
            logic.get_topic_list(user_id),
            'alertname':
            topic['topic_name'],
            'type':
            "bookmark",
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic':
            topic,
            'location':
            location,
            'relevant_locations':
            relevant_locations
        }
        content = self.render_template(template, variables)
        self.write(content)
Beispiel #4
0
    def get(self, alertid=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        variables = dict()
        variables['topic'] = logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))
        variables['username'] = str(tornado.escape.xhtml_escape(self.get_current_username()))
        variables['alerts'] = logic.get_topic_list(user_id)
        relevant_locations = logic.get_relevant_locations()
        variables['relevant_locations'] = relevant_locations
        variables['location'] = logic.get_current_location(tornado.escape.xhtml_escape(self.current_user))

        if alertid is not None:
            if logic.topic_exist(user_id):
                variables['title'] = "Edit Topic"
                variables['alert'] = logic.get_topic(alertid)
                variables['type'] = "editAlert"
            else:
                self.redirect("/Topics")
        else:
            if logic.get_topic_limit(user_id) == 0:
                self.redirect("/Topics")
            variables['title'] = "Create Topic"
            variables['alert'] = logic.get_topic(alertid)
            variables['type'] = "createAlert"
        content = self.render_template(template, variables)
        self.write(content)
Beispiel #5
0
    def get(self, argument=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))
        try:
            location = self.get_argument('location')
        except:
            location = logic.get_current_location(tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()

        if topic is None:
            self.redirect("/topicinfo")

        local_influencers = logic.get_local_influencers(topic['topic_id'], 0, location)
        variables = {
            'title': "Influencers",
            'alertname': topic['topic_name'],
            'alertid': topic['topic_id'],
            'location': location,
            'local_influencers': local_influencers['local_influencers'],
            'cursor': local_influencers['next_cursor'],
            'alerts': logic.get_topic_list(user_id),
            'type': "influencers",
            'username': str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic': topic,
            'relevant_locations': relevant_locations
        }

        content = self.render_template(template, variables)
        self.write(content)
Beispiel #6
0
 def post(self, topic_id=None):
     topic_id = self.get_argument("alertid")
     posttype = self.get_argument("posttype")
     user_id = tornado.escape.xhtml_escape(self.current_user)
     if posttype == u'remove':
         logic.delete_topic(topic_id, user_id)
     elif posttype == u'stop':
         logic.stop_topic(topic_id)
     elif posttype == u'start':
         logic.start_topic(topic_id)
     elif posttype == u'publish':
         logic.publish_topic(topic_id)
     elif posttype == u'unpublish':
         logic.unpublish_topic(topic_id)
     elif posttype == u'subscribe':
         logic.subsribe_topic(topic_id, user_id)
         logic.set_current_topic(user_id)
     elif posttype == u'unsubscribe':
         logic.unsubsribe_topic(topic_id, user_id)
         logic.set_current_topic(user_id)
     template = "alerts.html"
     variables = {
         'title': "Topics",
         'alerts': logic.get_topic_list(user_id),
         'type': "alertlist",
         'alertlimit': logic.get_topic_limit(user_id),
         'username': str(tornado.escape.xhtml_escape(self.get_current_username())),
         'topic': logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))
     }
     content = self.render_template(template, variables)
     dropdown = self.render_template("alertDropdownMenu.html", variables)
     self.write({'topic_list': content, 'dropdown_list': dropdown})
Beispiel #7
0
    def get(self):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()
        crons_log = logic.get_crons_log()

        if topic is None:
            self.redirect("/topicinfo")
        variables = {
            'title':
            "Crons Logs",
            'alerts':
            logic.get_topic_list(user_id),
            'type':
            "crons_log",
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic':
            topic,
            'location':
            location,
            'relevant_locations':
            relevant_locations,
            'crons':
            crons_log
        }
        content = self.render_template(template, variables)
        self.write(content)
Beispiel #8
0
 def get(self):
     user_id = tornado.escape.xhtml_escape(self.current_user)
     template = 'afterlogintemplate.html'
     topic = logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))
     location = logic.get_current_location(tornado.escape.xhtml_escape(self.current_user))
     relevant_locations = logic.get_relevant_locations()
     variables = {
         'title': "Topics",
         'alerts': logic.get_topic_list(user_id),
         'type': "alertlist",
         'alertlimit': logic.get_topic_limit(user_id),
         'username': str(tornado.escape.xhtml_escape(self.get_current_username())),
         'topic': topic,
         'location': location,
         'relevant_locations': relevant_locations
     }
     content = self.render_template(template, variables)
     self.write(content)
    def get(self, argument=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()

        if topic is None:
            self.redirect("/topicinfo")

        audience = logic.get_recommended_audience(topic['topic_id'], location,
                                                  'recommended', user_id, 0)
        variables = {
            'title':
            "Recommendations",
            'alertname':
            topic['topic_name'],
            'alertid':
            topic['topic_id'],
            'location':
            location,
            'audience':
            audience['audience'],
            'cursor':
            audience['next_cursor'],
            'alerts':
            logic.get_topic_list(user_id),
            'recom_filter':
            'recommended',
            'type':
            "recommendations",
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic':
            topic,
            'relevant_locations':
            relevant_locations
        }

        content = self.render_template(template, variables)
        self.write(content)
Beispiel #10
0
    def get(self, argument=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(user_id)
        print(" (GET) Getting audience for topic " + str(topic['topic_id']))
        try:
            location = self.get_argument('location')
        except:
            location = logic.get_current_location(
                tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()
        if topic is None:
            self.redirect("/topicinfo")
        audiences = logic.get_audience(topic['topic_id'], user_id, 0, location)
        audience_stats = logic.get_audience_stats(topic['topic_id'], location)
        variables = {
            'title':
            "Audience",
            'topic':
            topic,
            'audiences':
            audiences['audiences'],
            'cursor':
            audiences['next_cursor'],
            'alerts':
            logic.get_topic_list(user_id),
            'type':
            "audiences",
            'audience_stats':
            audience_stats,
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'location':
            location,
            'relevant_locations':
            relevant_locations
        }

        content = self.render_template(template, variables)
        self.write(content)
Beispiel #11
0
    def get(self, argument=None):
        user_id = tornado.escape.xhtml_escape(self.current_user)
        template = 'afterlogintemplate.html'
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        relevant_locations = logic.get_relevant_locations()
        if topic is None:
            self.redirect("/topicinfo")

        data = logic.get_hashtag_aggregations(topic['topic_id'])
        variables = {
            'title':
            "Hashtag Charts",
            'data':
            data['data'],
            'sorted':
            data['sorted'],
            'table_data':
            data['table_data'],
            'alertid':
            topic['topic_id'],
            'alerts':
            logic.get_topic_list(user_id),
            'alertname':
            topic['topic_name'],
            'type':
            "hashtag_chart",
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic':
            topic,
            'location':
            location,
            'relevant_locations':
            relevant_locations
        }
        content = self.render_template(template, variables)
        self.write(content)
Beispiel #12
0
 def get(self):
     user_id = tornado.escape.xhtml_escape(self.current_user)
     template = 'afterlogintemplate.html'
     topic = logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))
     location = logic.get_current_location(tornado.escape.xhtml_escape(self.current_user))
     relevant_locations = logic.get_relevant_locations()
     user = logic.get_user(user_id)
     auth_url = logic.get_twitter_auth_url()
     variables = {
         'title': "My Profile",
         'type': "profile",
         'username': user['username'],
         'country': user['country'],
         'alerts': logic.get_topic_list(user_id),
         'topic': topic,
         'location': location,
         'relevant_locations': relevant_locations,
         'auth_url': auth_url[0]
     }
     self.set_secure_cookie("request_token", str(auth_url[1]))
     content = self.render_template(template, variables)
     self.write(content)
Beispiel #13
0
 def get(self, tweet_id=None):
     user_id = tornado.escape.xhtml_escape(self.current_user)
     template = 'afterlogintemplate.html'
     changing_topic = int(self.get_argument("topic_id", -1))
     topic = logic.get_current_topic(
         tornado.escape.xhtml_escape(self.current_user))
     location = logic.get_current_location(
         tornado.escape.xhtml_escape(self.current_user))
     if changing_topic != -1:
         topic['topic_id'] = changing_topic
         template = 'renderTweets.html'
     relevant_locations = logic.get_relevant_locations()
     new_tweet = False
     if tweet_id is not None:
         news_id = int(self.get_argument("news_id", -1))
         date = self.get_argument("date", "")
         new_tweet = int(tweet_id) == -1
         if new_tweet:
             twitter_user = logic.get_twitter_user(user_id)
             if twitter_user['twitter_id'] == '':
                 self.redirect("/twitter_auth")
         sub_type = "item"
         tweets = logic.get_publish_tweet(topic['topic_id'], user_id,
                                          tweet_id, news_id, date)
     else:
         status = int(self.get_argument("status", 0))
         request_type = self.get_argument("request_type", "")
         if request_type == 'ajax':
             template = 'renderTweets.html'
         sub_type = "list"
         tweets = logic.get_publish_tweets(topic['topic_id'], user_id,
                                           status)
     twitter_user = logic.get_twitter_user(user_id)
     variables = {
         'title':
         "Tweets",
         'alerts':
         logic.get_topic_list(user_id),
         'type':
         "tweets",
         'sub_type':
         sub_type,
         'new_tweet':
         new_tweet,
         'alertlimit':
         logic.get_topic_limit(user_id),
         'username':
         str(tornado.escape.xhtml_escape(self.get_current_username())),
         'topic':
         topic,
         'location':
         location,
         'relevant_locations':
         relevant_locations,
         'tweets':
         tweets,
         'twitter_user':
         twitter_user
     }
     content = self.render_template(template, variables)
     self.write(content)