Exemplo n.º 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()
        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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def post(self):
     influencer_id = str(self.get_argument("influencer_id"))
     topic_id = logic.get_current_topic(tornado.escape.xhtml_escape(self.current_user))['topic_id']
     is_hide = (self.get_argument("is_hide") == "true")
     description = self.get_argument("description")
     user_id = tornado.escape.xhtml_escape(self.current_user)
     location = logic.get_current_location(tornado.escape.xhtml_escape(self.current_user))
     logic.hide_influencer(topic_id, user_id, influencer_id, description, is_hide, location)
     self.write("")
Exemplo n.º 8
0
    def post(self, argument=None):
        variables = {}
        user_id = tornado.escape.xhtml_escape(self.current_user)
        topic = logic.get_current_topic(user_id)
        topic_id = topic['topic_id']
        print(" (POST) Getting audience for topic " + str(topic_id))
        try:
            location = self.get_argument('location')
            print("got location from JS.")
        except:
            location = logic.get_current_location(
                tornado.escape.xhtml_escape(self.current_user))

        if argument is not None:  # scroll
            print("Scrolled down.")
            template = 'audienceTemplate.html'
            try:
                next_cursor = self.get_argument('next_cursor')
            except:
                next_cursor = 0
                pass
            try:
                audiences = logic.get_audience(topic_id, user_id,
                                               int(next_cursor), location)
                audience_stats = logic.get_audience_stats(topic_id, location)

                variables = {
                    'audiences': audiences['audiences'],
                    'audience_stats': audience_stats,
                    'cursor': audiences['next_cursor']
                }
            except Exception as e:
                print(e)
                self.write("")
        else:  # change in topic or location dropdown
            try:
                topic_id = self.get_argument('topic_id')
                print("Changed topic.")
            except:
                print("Changed location.")
            template = 'alertAudience.html'
            user_id = tornado.escape.xhtml_escape(self.current_user)
            try:
                audiences = logic.get_audience(topic_id, user_id, 0, location)
                audience_stats = logic.get_audience_stats(topic_id, location)

                variables = {
                    'audiences': audiences['audiences'],
                    'audience_stats': audience_stats,
                    'topic_id': topic_id,
                    'cursor': audiences['next_cursor']
                }
            except Exception as e:
                print(e)
                self.write("")
        content = self.render_template(template, variables)
        self.write(content)
Exemplo n.º 9
0
    def post(self, argument=None):
        variables = {}
        topic = logic.get_current_topic(
            tornado.escape.xhtml_escape(self.current_user))
        location = logic.get_current_location(
            tornado.escape.xhtml_escape(self.current_user))
        user_id = tornado.escape.xhtml_escape(self.current_user)
        filter = self.get_argument('filter')

        if argument is not None:
            template = 'recommendationsTemplate.html'
            try:
                next_cursor = self.get_argument('next_cursor')
            except:
                next_cursor = 0
                pass
            try:
                # filter is "rated" or "recommended"
                audience = logic.get_recommended_audience(
                    topic['topic_id'], location, filter, user_id,
                    int(next_cursor))
                variables = {
                    'audience': audience['audience'],
                    'cursor': audience['next_cursor'],
                    'recom_filter': filter
                }
            except Exception as e:
                print(e)
                self.write("")
        else:
            template = 'alertRecommendations.html'
            try:
                audience = logic.get_recommended_audience(
                    topic['topic_id'], location, filter, user_id, 0)
                variables = {
                    'audience': audience['audience'],
                    'alertid': topic['topic_id'],
                    'cursor': audience['next_cursor'],
                    'recom_filter': filter
                }
            except Exception as e:
                print(e)
                self.write("")
        content = self.render_template(template, variables)
        self.write(content)
Exemplo n.º 10
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)
Exemplo n.º 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")

        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)
Exemplo n.º 12
0
 def get(self):
     topic_id = self.get_argument('topic_id')
     filter = self.get_argument('filter')
     try:
         cursor = self.get_argument('cursor')
     except:
         cursor = 0
         pass
     try:
         location = self.get_argument(
             'location')  # this will be called upon a change in location
     except:
         location = logic.get_current_location(
             tornado.escape.xhtml_escape(self.current_user)
         )  # this will be called when new events are loading (cursoring)
     print("CURSOR:" + str(cursor))
     document = logic.get_events(topic_id, filter, location, cursor)
     self.write(
         self.render_template("single-event.html", {"document": document}))
Exemplo n.º 13
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)
Exemplo n.º 14
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)
Exemplo n.º 15
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)
Exemplo n.º 16
0
    def post(self, argument=None):
        variables = {}
        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))
        user_id = tornado.escape.xhtml_escape(self.current_user)

        if argument is not None:
            template = 'influencersTemplate.html'
            try:
                next_cursor = self.get_argument('next_cursor')
            except:
                next_cursor = 0
                pass
            try:
                local_influencers = logic.get_local_influencers(topic['topic_id'], int(next_cursor), location)
                variables = {
                    'local_influencers': local_influencers['local_influencers'],
                    'cursor': local_influencers['next_cursor']
                }
            except Exception as e:
                print(e)
                self.write("")
        else:
            template = 'alertInfluencers.html'
            try:
                local_influencers = logic.get_local_influencers(topic['topic_id'], 0, location)
                variables = {
                    'local_influencers': local_influencers['local_influencers'],
                    'alertid': topic['topic_id'],
                    'cursor': local_influencers['next_cursor']
                }
            except Exception as e:
                print(e)
                self.write("")
        content = self.render_template(template, variables)
        self.write(content)
Exemplo n.º 17
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)