예제 #1
0
 def get(self):
     films = top_films()
     loggedin = self.user
     if loggedin:
         username = self.user.name
         myfilms = my_top_films(username)
     else:
         username = '******'
         myfilms = []
     self.response.headers['Content-Type'] = 'text/html'
     self.render("topfilms.html", films=films,
                 myfilms=myfilms,
                 username=username)
예제 #2
0
 def get(self):
     films = top_films()
     loggedin = self.user
     if loggedin:
         username = self.user.name
         myfilms = my_top_films(username)
     else:
         username = '******'
         myfilms = []
     self.response.headers['Content-Type'] = 'text/html'
     self.render("topfilms.html",
                 films=films,
                 myfilms=myfilms,
                 username=username)
예제 #3
0
 def post(self):
     if not self.user:
         self.redirect("/")
     title = self.request.get('title')
     val = self.request.cookies.get('user_id').split('|')[0]
     user = User.by_id(int(val)).name
     myrating = self.request.get('rating')
     myblurb = self.request.get('blurb')
     keywords = self.request.get('keywords')
     if title:
         title_check = Film.by_name(title)
         if not title_check:
             set_fetch_timeout(60000)
             urlfetch.set_default_fetch_deadline(60000)
             search = check_cache(title)
             if search[1] and search[0]:
                 rating = search[0][1]
                 blurb = search[1]
                 film = Film(parent=film_key(),
                             title=title,
                             rating=rating,
                             blurb=blurb,
                             keywords=keywords)
                 film.put()
                 top_films(True)
                 mytitle_check = MyFilm.by_name(title)
                 if mytitle_check:
                     # if in myfilm collection go to that film page
                     self.render('/index.html')
                 else:
                     myfilm = MyFilm(parent=film_key(),
                                     title=title,
                                     user=user,
                                     rating=myrating,
                                     blurb=myblurb,
                                     keywords=keywords)
                     myfilm.put()
                     self.render('/index.html')
             else:
                 error = 'not found'
                 mytitle_check = MyFilm.by_name(title)
                 if mytitle_check:
                     self.render('/index.html')
                 self.render("/index.html", title=title,
                             error=error)
         else:
             mytitle_check = MyFilm.by_name(title)
             if mytitle_check:
                 # if in myfilm collection go to that film page
                 self.render('/index.html')
             else:
                 myfilm = MyFilm(parent=film_key(),
                                 title=title,
                                 user=user,
                                 rating=myrating,
                                 blurb=myblurb,
                                 keywords=keywords)
                 myfilm.put()
                 self.render('/index.html')
     else:
         error = "Leave, we've fallen, said the other . . ."
         self.render("/index.html", title=title,
                     error=error)
예제 #4
0
 def post(self):
     if not self.user:
         self.redirect("/")
     title = self.request.get('title')
     val = self.request.cookies.get('user_id').split('|')[0]
     user = User.by_id(int(val)).name
     myrating = self.request.get('rating')
     myblurb = self.request.get('blurb')
     keywords = self.request.get('keywords')
     if title:
         title_check = Film.by_name(title)
         if not title_check:
             set_fetch_timeout(60000)
             urlfetch.set_default_fetch_deadline(60000)
             search = check_cache(title)
             if search[1] and search[0]:
                 rating = search[0][1]
                 blurb = search[1]
                 film = Film(parent=film_key(),
                             title=title,
                             rating=rating,
                             blurb=blurb,
                             keywords=keywords)
                 film.put()
                 top_films(True)
                 mytitle_check = MyFilm.by_name(title)
                 if mytitle_check:
                     # if in myfilm collection go to that film page
                     self.render('/index.html')
                 else:
                     myfilm = MyFilm(parent=film_key(),
                                     title=title,
                                     user=user,
                                     rating=myrating,
                                     blurb=myblurb,
                                     keywords=keywords)
                     myfilm.put()
                     self.render('/index.html')
             else:
                 error = 'not found'
                 mytitle_check = MyFilm.by_name(title)
                 if mytitle_check:
                     self.render('/index.html')
                 self.render("/index.html", title=title, error=error)
         else:
             mytitle_check = MyFilm.by_name(title)
             if mytitle_check:
                 # if in myfilm collection go to that film page
                 self.render('/index.html')
             else:
                 myfilm = MyFilm(parent=film_key(),
                                 title=title,
                                 user=user,
                                 rating=myrating,
                                 blurb=myblurb,
                                 keywords=keywords)
                 myfilm.put()
                 self.render('/index.html')
     else:
         error = "Leave, we've fallen, said the other . . ."
         self.render("/index.html", title=title, error=error)