def get(self):
     current_time = datetime.datetime.now()
     all_streams = Stream.query()
     for stream in all_streams:
         for date in stream.view_queue:
             minback = current_time - datetime.timedelta(hours=1)
             if date < minback:
                 stream.view_queue.remove(date)
                 stream.views = stream.views - 1
         stream.put()
 def get(self):
     current_time = datetime.datetime.now()
     all_streams = Stream.query()
     for stream in all_streams:
         for date in stream.view_queue:
             minback = current_time - datetime.timedelta(hours=1)
             if date < minback:
                 stream.view_queue.remove(date)
                 stream.views = stream.views - 1
         stream.put()
Example #3
0
    def get(self):

        #Get the list of streams
        images = {'stream_names': [], 'image_urls': []}
        streams = Stream.query().order(-Stream.date_last_added)
        for stream in streams:
            images['stream_names'].append(stream.name)
            images['image_urls'].append(stream.cover_image)

        image_json = json.dumps(images, indent=4, separators=(',', ': '))
        self.response.write(image_json)
    def get(self):

        #Get the list of streams
        images = {'stream_names': [], 'image_urls': []}
        streams = Stream.query().order(-Stream.date_last_added)
        for stream in streams:
            images['stream_names'].append(stream.name)
            images['image_urls'].append(stream.cover_image)

        image_json = json.dumps(images,indent=4, separators=(',', ': '))
        self.response.write(image_json)
    def get(self):
        self.cache('manage')

        JINJA_ENVIRONMENT = jinja2.Environment(
        loader=jinja2.FileSystemLoader('templates'),
        extensions=['jinja2.ext.autoescape'],
        autoescape=True)

        user = users.get_current_user()
        user_id = user.user_id()
        user_email = user.email()

        #Get the list of streams
        my_streams = Stream.query(Stream.owner_id == user_id)
        subscribed_streams = Stream.query(Stream.subscribed_users.IN([user_email]))
        template_values = {
            'my_streams':my_streams,
            'subscribed_streams':subscribed_streams
        }

        template = JINJA_ENVIRONMENT.get_template('ManagementPage.html')
        self.response.write(template.render(template_values))
    def get(self):
        self.cache('manage')

        JINJA_ENVIRONMENT = jinja2.Environment(
            loader=jinja2.FileSystemLoader('templates'),
            extensions=['jinja2.ext.autoescape'],
            autoescape=True)

        user = users.get_current_user()
        user_id = user.user_id()
        user_email = user.email()

        #Get the list of streams
        my_streams = Stream.query(Stream.owner_id == user_id)
        subscribed_streams = Stream.query(
            Stream.subscribed_users.IN([user_email]))
        template_values = {
            'my_streams': my_streams,
            'subscribed_streams': subscribed_streams
        }

        template = JINJA_ENVIRONMENT.get_template('ManagementPage.html')
        self.response.write(template.render(template_values))
    def get(self):

        user_email = cgi.escape(self.request.get('user_email'))


        #Get the list of streams
        subscribed_streams = Stream.query(Stream.subscribed_users.IN([user_email]))
        images = {'stream_names': [], 'image_urls': [],}
        for stream in subscribed_streams:
            images['stream_names'].append(stream.name)
            images['image_urls'].append(stream.cover_image)

        image_json = json.dumps(images,indent=4, separators=(',', ': '))
        self.response.write(image_json)
    def get(self):

        user_email = cgi.escape(self.request.get('user_email'))

        #Get the list of streams
        subscribed_streams = Stream.query(
            Stream.subscribed_users.IN([user_email]))
        images = {
            'stream_names': [],
            'image_urls': [],
        }
        for stream in subscribed_streams:
            images['stream_names'].append(stream.name)
            images['image_urls'].append(stream.cover_image)

        image_json = json.dumps(images, indent=4, separators=(',', ': '))
        self.response.write(image_json)
Example #9
0
    def get(self):
        # self.setup('trending')
        self.cache('trending')
        JINJA_ENVIRONMENT = jinja2.Environment(
        loader=jinja2.FileSystemLoader('templates'),
        extensions=['jinja2.ext.autoescape'],
        autoescape=True)

        #Get the list of streams
        streams = Stream.query().order(-Stream.views)


        template_values = {
            'streams':streams
        }

        template = JINJA_ENVIRONMENT.get_template('TrendingStreamsPage.html')
        self.response.write(template.render(template_values))
Example #10
0
    def get(self):
        self.cache('view')

        JINJA_ENVIRONMENT = jinja2.Environment(
        loader=jinja2.FileSystemLoader('templates'),
        extensions=['jinja2.ext.autoescape'],
        autoescape=True)

        user = users.get_current_user()
        user_id = user.user_id()

        #Get the list of streams
        my_streams = Stream.query(Stream.owner_id == user_id).order(Stream.timestamp)
        template_values = {
            'my_streams':my_streams,
        }

        template = JINJA_ENVIRONMENT.get_template('ViewAllStreamsPage.html')
        self.response.write(template.render(template_values))
Example #11
0
    def get(self):
        JINJA_ENVIRONMENT = jinja2.Environment(
        loader=jinja2.FileSystemLoader('templates'),
        extensions=['jinja2.ext.autoescape'],
        autoescape=True)

        user = users.get_current_user()
        login_url = users.create_login_url('/management')

        if user :
            self.redirect('/management')

        #Get the list of streams
        streams = Stream.query()

        template_values = {
            'login_url':login_url,
        }

        template = JINJA_ENVIRONMENT.get_template('MainPage.html')
        self.response.write(template.render(template_values))
Example #12
0
 def get(self):
     message = mail.EmailMessage()
     user = users.get_current_user()
     message.sender = user.email()
     message.subject = "Trending"
     message.to = user.email()
     #Get the list of streams
     streams = Stream.query().order(-Stream.views)
     i = 0
     top = []
     for stream in streams:
         if i == 3:
             break
         top.append(stream.name)
         i = i + 1
     if len(top) == 3:
         message.body = "'Top 3 Trending Streams: %s %s %s'" % (
             top[0], top[1], top[2])
     else:
         message.body = "'There are not 3 streams in the datastore'"
     message.send()
Example #13
0
    def get(self):
        JINJA_ENVIRONMENT = jinja2.Environment(
            loader=jinja2.FileSystemLoader('templates'),
            extensions=['jinja2.ext.autoescape'],
            autoescape=True)

        user = users.get_current_user()
        login_url = users.create_login_url('/management')

        if user:
            self.redirect('/management')

        #Get the list of streams
        streams = Stream.query()

        template_values = {
            'login_url': login_url,
        }

        template = JINJA_ENVIRONMENT.get_template('MainPage.html')
        self.response.write(template.render(template_values))
Example #14
0
    def cache(self, currentTab):
        JINJA_ENVIRONMENT = jinja2.Environment(
            loader=jinja2.FileSystemLoader('templates'),
            extensions=['jinja2.ext.autoescape'],
            autoescape=True)

        user = users.get_current_user()
        user_id = user.user_id()
        logout_url = users.create_logout_url('/')

        #welcome to Connexus
        userInfo = {'user': user, 'logout_url': logout_url}

        template = JINJA_ENVIRONMENT.get_template('Welcome.html')
        self.response.write(template.render(userInfo))

        #Get the list of streams
        streams = Stream.query()
        taglist = []

        streamNames = []
        for stream in streams:
            streamNames.append(str(stream.name))
            for tag in stream.tags:
                if tag not in taglist:
                    streamNames.append(tag)
                    taglist.append(tag)

        template_values = {'streams': streams}

        template = JINJA_ENVIRONMENT.get_template('Search.html')
        self.response.write(template.render(streams=json.dumps(streamNames)))

        #test search header
        searchHead = JINJA_ENVIRONMENT.get_template('Header.html')
        self.response.write(searchHead.render(current=currentTab))