コード例 #1
0
 def post(self):
     user = users.get_current_user()
     name = self.request.get("name")
     emails = re.findall(r'[^(?: |\n|,)].+', self.request.get("email"))
     extra_message = self.request.get("extra_message")
     tag = self.request.get("tag")
     cover_image_url = self.request.get("cover_image_url")
     for email in emails:
         if not is_valid_email(
                 email):  # take from http://www.regular-expressions.info/
             jumpToErrorPage(
                 self, 'Stream is not created! "' + email +
                 '" is not a valid email!')
             return
     if len(
             Stream.query(Stream.user == user.email(),
                          Stream.name == name,
                          ancestor=getStreamKey()).fetch()) > 0:
         jumpToErrorPage(
             self, 'Stream is not created! Name "' + name +
             '" already exists. Please use another name.')
         return
     stream = createStream(user.email(), name, tag, cover_image_url)
     addStreamToSearchService(stream)
     sendSubscribeInvitationEmail(emails, extra_message, stream)
     self.redirect(urls.URL_MANAGEMENT_PAGE, permanent=True)
コード例 #2
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))
コード例 #3
0
 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))
コード例 #4
0
 def getOwnedStreams(self, request):
     user = endpoints.get_current_user()
     if user:
         return RespondStreams(streams=[getStreamInfo(stream) for stream in Stream.query(Stream.user == user.email(),
                               ancestor=getStreamKey()).order(-Stream.last_newpic_time, -Stream.pic_num, Stream.name,
                               -Stream.create_time)])
     else:
         return RespondStreams(streams=[])
コード例 #5
0
 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))
コード例 #6
0
 def post(self):
     user = users.get_current_user()
     name = self.request.get("name")
     emails = re.findall(r'[^(?: |\n|,)].+', self.request.get("email"))
     extra_message = self.request.get("extra_message")
     tag = self.request.get("tag")
     cover_image_url = self.request.get("cover_image_url")
     for email in emails:
         if not is_valid_email(email): # take from http://www.regular-expressions.info/
             jumpToErrorPage(self, 'Stream is not created! "'+email+'" is not a valid email!')
             return
     if len(Stream.query( Stream.user==user.email(), Stream.name==name, ancestor=getStreamKey()).fetch()) > 0:
         jumpToErrorPage(self, 'Stream is not created! Name "'+name+'" already exists. Please use another name.')
         return
     stream = createStream(user.email(), name, tag, cover_image_url)
     addStreamToSearchService(stream)
     sendSubscribeInvitationEmail(emails, extra_message, stream)
     self.redirect(urls.URL_MANAGEMENT_PAGE, permanent=True)
コード例 #7
0
 def getAllStreams(self, request):
     return RespondStreams(streams=[getStreamInfo(stream) for stream in Stream.query(ancestor=getStreamKey())
                             .order(-Stream.last_newpic_time, -Stream.pic_num, Stream.name, -Stream.create_time)])