Пример #1
0
 def get(self):
     error = self.request.get('error')
     if not error:
         error = "This page is not available!"
     template_dict = urls.getUrlDir()
     template_dict['error'] = error
     self.response.write(urls.getTemplate(template_name).render(template_dict))
 def get(self):
     user = users.get_current_user()
     streams = Stream.query(ancestor=getStreamKey()).order(-Stream.last_newpic_time, -Stream.viewCount,
                            -Stream.pic_num, Stream.name, -Stream.create_time)
     template_dict = urls.getUrlDir()
     template_dict['cur_page'] = 'view_all_stream'
     template_dict["streams"] = streams
     self.response.write(urls.getTemplate(template_name).render(template_dict))
 def get(self):
     user = users.get_current_user()
     trendingStreams = getTopStreams(trendingStream_num)
     template_dict = urls.getUrlDir()
     template_dict['cur_page'] = 'trending_streams'
     template_dict['trendingStreams'] = trendingStreams
     template_dict['email_setting'] = getEmailSetting(user.email())
     self.response.write(urls.getTemplate(template_name).render(template_dict))
 def get(self):
     user = users.get_current_user()
     streams = Stream.query(ancestor=getStreamKey()).order(
         -Stream.last_newpic_time, -Stream.viewCount, -Stream.pic_num, Stream.name, -Stream.create_time
     )
     template_dict = urls.getUrlDir()
     template_dict["cur_page"] = "view_all_stream"
     template_dict["streams"] = streams
     self.response.write(urls.getTemplate(template_name).render(template_dict))
Пример #5
0
 def get(self):
     user = users.get_current_user()
     streams = Stream.query(Stream.user == user.email(),
                            ancestor=getStreamKey()).order(
                                -Stream.last_newpic_time, -Stream.pic_num,
                                Stream.name, -Stream.create_time)
     subscribed = Stream.query(Stream.subscribers == user.email(),
                               ancestor=getStreamKey()).order(
                                   -Stream.last_newpic_time,
                                   -Stream.pic_num, Stream.name,
                                   -Stream.create_time)
     template_dict = urls.getUrlDir()
     template_dict['cur_page'] = 'management'
     template_dict["streams"] = streams
     template_dict["subscribed"] = subscribed
     self.response.write(
         urls.getTemplate(template_name).render(template_dict))
Пример #6
0
 def get(self):
     if(self.request.get('request_suggestion')):
         self.response.write(json.dumps(search_suggestion(self.request.get('query_key'), 20)))
         return
     template_dict = urls.getUrlDir()
     key_word = self.request.get('key_word')
     if key_word:
         offset = self.request.get('offset')
         if offset:
             offset = int(offset)
         else:
             offset = 0
         template_dict['key_word'] = key_word
         template_dict['streams'] = search_streams(key_word)
         template_dict['offset'] = offset
         template_dict['num_results_per_page'] = num_results_per_page
         template_dict['num_pages_displayed'] = num_pages_displayed
         self.response.write(urls.getTemplate(template_name).render(template_dict))
     else:
         self.error(400)
         jumpToErrorPage(self, 'No search key found!')
Пример #7
0
 def get(self):
     if (self.request.get('request_suggestion')):
         self.response.write(
             json.dumps(search_suggestion(self.request.get('query_key'),
                                          20)))
         return
     template_dict = urls.getUrlDir()
     key_word = self.request.get('key_word')
     if key_word:
         offset = self.request.get('offset')
         if offset:
             offset = int(offset)
         else:
             offset = 0
         template_dict['key_word'] = key_word
         template_dict['streams'] = search_streams(key_word)
         template_dict['offset'] = offset
         template_dict['num_results_per_page'] = num_results_per_page
         template_dict['num_pages_displayed'] = num_pages_displayed
         self.response.write(
             urls.getTemplate(template_name).render(template_dict))
     else:
         self.error(400)
         jumpToErrorPage(self, 'No search key found!')
Пример #8
0
 def get(self):
     template_dict = urls.getUrlDir()
     template_dict['cur_page'] = 'create_stream'
     self.response.write(
         urls.getTemplate(template_name).render(template_dict))
Пример #9
0
 def get(self):
     template_dict = urls.getUrlDir()
     template_dict['cur_page'] = 'create_stream'
     self.response.write(urls.getTemplate(template_name).render(template_dict))
Пример #10
0
 def get(self):
     user = users.get_current_user()
     streamId = self.request.get("id")
     if not streamId:
         logging.error("Unable to get id from url")
         self.error(400)
         jumpToErrorPage(self)
         return
     stream = Stream.get_by_id(int(streamId), getStreamKey())
     if not stream:
         logging.error("Unable to get stream with id " + streamId)
         self.error(400)
         jumpToErrorPage(
             self, 'Unable to find the stream! The stream may be deleted!')
         return
     if self.request.get('newest_pic'):
         self.response.write(
             get_serving_url(
                 Image.query(ancestor=stream.key).order(
                     -Image.create_time).get().img))
         return
     if (self.request.get('geo_info')):
         timeline = self.request.get_all('timeline[]')
         if (timeline is None) or len(timeline) < 2:
             self.error(400)
             return
         startDate = datetime.now() - timedelta(365 - int(timeline[0]))
         endDate = datetime.now() - timedelta(365 - int(timeline[1]))
         images = Image.query(Image.create_time >= startDate,
                              Image.create_time <= endDate,
                              ancestor=stream.key)
         images = filter(
             lambda x: x.latitude >= -90.0 and x.latitude <= 90.0 and x.
             longitude >= -180.0 and x.longitude <= 180.0, images)
         self.response.write(
             json.dumps([{
                 'url': get_serving_url(img.img),
                 'latitude': img.latitude,
                 'longitude': img.longitude
             } for img in images]))
         return
     if self.request.get('upload'):
         self.response.write(
             blobstore.create_upload_url(
                 urls.URL_VIEW_STREAM_PAGE + urls.URL_UPLOAD_HANDLER +
                 '/?' + urllib.urlencode({'id': streamId})))
         return
     template_dict = urls.getUrlDir()
     template_dict['images'] = [
         get_serving_url(x.img)
         for x in Image.query(ancestor=stream.key).order(-Image.create_time)
     ]
     template_dict['id'] = streamId
     template_dict['stream'] = stream
     template_dict['images_per_page'] = images_per_page
     if stream.user == user.email():
         template_dict['is_owner'] = True
     else:
         template_dict['is_owner'] = False
         increaseViewNum(stream)
         stream.viewCount = stream.viewCount + 1
         template_dict['subscribed'] = user.email() in stream.subscribers
         stream.put()
     self.response.write(
         urls.getTemplate(template_name).render(template_dict))