예제 #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")

        tweets = logic.get_tweets(topic['topic_id'])
        variables = {
            'title':
            "Feed",
            'alerts':
            logic.get_topic_list(user_id),
            'type':
            "feed",
            'tweets':
            tweets,
            'username':
            str(tornado.escape.xhtml_escape(self.get_current_username())),
            'topic':
            logic.get_current_topic(
                tornado.escape.xhtml_escape(self.current_user)),
            'location':
            location,
            'relevant_locations':
            relevant_locations
        }

        content = self.render_template(template, variables)
        self.write(content)
예제 #2
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})
예제 #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))
        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)
예제 #4
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)
예제 #5
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)
예제 #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()
        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)
예제 #7
0
 def post(self):
     event_link = str(self.get_argument("event_link"))
     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)
     logic.hide_event(topic_id, user_id, event_link, description, is_hide)
     self.write("")
예제 #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)
예제 #9
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("")
예제 #10
0
 def post(self):
     topic = logic.get_current_topic(
         tornado.escape.xhtml_escape(self.current_user))
     template = 'hashtags.html'
     topic_id = self.get_argument('topic_id', '')
     if topic_id == '':
         topic_id = topic['topic_id']
     topic_id = int(topic_id)
     data = logic.get_hashtag_aggregations(topic_id)
     variables = {
         'data': data['data'],
         'sorted': data['sorted'],
         'table_data': data['table_data'],
     }
     content = self.render_template(template, variables)
     self.write(content)
예제 #11
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)
예제 #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()
     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)
예제 #13
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)
예제 #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)
예제 #15
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)
예제 #16
0
 def post(self, tweet_id=None):
     topic = logic.get_current_topic(
         tornado.escape.xhtml_escape(self.current_user))
     tweet_id = self.get_argument("tweet_id")
     posttype = self.get_argument("posttype")
     user_id = tornado.escape.xhtml_escape(self.current_user)
     if posttype == u'remove':
         logic.delete_publish_tweet(topic['topic_id'], user_id, tweet_id)
     elif posttype == u'update':
         news_id = self.get_argument("news_id")
         date = self.get_argument("date")
         title = self.get_argument("title")
         description = self.get_argument("tweet_link_description")
         text = self.get_argument("text")
         image_url = self.get_argument("image_url")
         logic.update_publish_tweet(topic['topic_id'], user_id, tweet_id,
                                    date, text, news_id, title, description,
                                    image_url)
     if tweet_id is not None:
         self.redirect("/Tweets")
     else:
         self.write({'response': True})
예제 #17
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)
예제 #18
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)
예제 #19
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)