Ejemplo n.º 1
0
 def post(self):
     if not self.user:
         self.redirect("/")
     title = self.request.get('title')
     if title:
         set_fetch_timeout(60000)
         urlfetch.set_default_fetch_deadline(60000)
         search = check_cache(title)
         if search:
             rating = search[0][1]
             blurb = search[1]
             film = Film(parent=film_key(),
                         title=title,
                         rating=rating,
                         blurb=blurb)
             film.put()
             top_films(True)
             self.redirect('/')
         else:
             error = 'not found'
             self.render("newmyfilm.html", title=title,
                         error=error)
     else:
         error = "darf"
         self.render("newmyfilm.html", title=title,
                     error=error)
Ejemplo n.º 2
0
    def post(self):
        def saveFilm(film_obj, user=False):
            if user:
                film_obj.put()
                user_title = film_obj.user + '|' + film_obj.title
                CACHED[user_title] = film_obj.as_dict()
                return
            else:
                film_obj.put()
                CACHED[title] = [film_obj]
                return

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

        if self.format == 'json':
            title = self.request.get('title')
            val = self.request.cookies.get('user_id').split('|')[0]
            user = User.by_id(int(val)).name
            rating = self.request.get('rating')
            blurb = self.request.get('blurb')
            if title and user:
                mytitle_check = MyFilm.by_name(title)
                title_check = Film.by_name(title)
                if not mytitle_check:
                    myfilm = MyFilm(parent=film_key(),
                                    title=title,
                                    user=user,
                                    rating=rating,
                                    blurb=blurb)
                    saveFilm(myfilm, True)
                    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)
                            saveFilm(film)
                            top_films(True)
                            return self.render_json(myfilm.as_dict())
                        else:
                            myfilm = Film(title='none',
                                          rating='none',
                                          blurb='none')
                            return self.render_json(myfilm.as_dict())
                    else:
                        return self.render_json(myfilm.as_dict())
                else:
                    film = mytitle_check
                    return self.render_json(myfilm.as_dict())
            else:
                self.error(404)
                return
Ejemplo n.º 3
0
    def post(self):
        def saveFilm(film_obj, user=False):
            if user:
                film_obj.put()
                user_title = film_obj.user + '|' + film_obj.title
                CACHED[user_title] = film_obj.as_dict()
                return
            else:
                film_obj.put()
                CACHED[title] = [film_obj]
                return

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

        if self.format == 'json':
            title = self.request.get('title')
            val = self.request.cookies.get('user_id').split('|')[0]
            user = User.by_id(int(val)).name
            rating = self.request.get('rating')
            blurb = self.request.get('blurb')
            if title and user:
                mytitle_check = MyFilm.by_name(title)
                title_check = Film.by_name(title)
                if not mytitle_check:
                    myfilm = MyFilm(parent=film_key(),
                                    title=title,
                                    user=user,
                                    rating=rating,
                                    blurb=blurb)
                    saveFilm(myfilm, True)
                    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)
                            saveFilm(film)
                            top_films(True)
                            return self.render_json(myfilm.as_dict())
                        else:
                            myfilm = Film(title='none',
                                          rating='none',
                                          blurb='none')
                            return self.render_json(myfilm.as_dict())
                    else:
                        return self.render_json(myfilm.as_dict())
                else:
                    film = mytitle_check
                    return self.render_json(myfilm.as_dict())
            else:
                self.error(404)
                return
Ejemplo n.º 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
     rating = self.request.get('rating')
     blurb = self.request.get('blurb')
     if title:
         title_check = MyFilm.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:
                 myfilm = MyFilm(parent=film_key(),
                                 title=title,
                                 user=user,
                                 rating=rating,
                                 blurb=blurb)
                 myfilm.put()
                 t = Film.by_name(title)
                 if t:
                     self.redirect('/')
                 else:
                     rating = search[0][1]
                     blurb = search[1]
                     u = Film(parent=film_key(),
                              title=title,
                              rating=rating,
                              blurb=blurb)
                     u.put()
                     top_films(True)
                     self.redirect('/')
             else:
                 error = 'not found'
                 self.render("/admin/newmyfilm.html", title=title,
                             error=error)
         else:
             self.redirect('/')
     else:
         error = "darf"
         self.render("/admin/newmyfilm.html", title=title,
                     error=error)
Ejemplo n.º 5
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
     rating = self.request.get('rating')
     blurb = self.request.get('blurb')
     if title:
         title_check = MyFilm.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:
                 myfilm = MyFilm(parent=film_key(),
                                 title=title,
                                 user=user,
                                 rating=rating,
                                 blurb=blurb)
                 myfilm.put()
                 t = Film.by_name(title)
                 if t:
                     self.redirect('/')
                 else:
                     rating = search[0][1]
                     blurb = search[1]
                     u = Film(parent=film_key(),
                              title=title,
                              rating=rating,
                              blurb=blurb)
                     u.put()
                     top_films(True)
                     self.redirect('/')
             else:
                 error = 'not found'
                 self.render("/admin/newmyfilm.html",
                             title=title,
                             error=error)
         else:
             self.redirect('/')
     else:
         error = "darf"
         self.render("/admin/newmyfilm.html", title=title, error=error)
Ejemplo n.º 6
0
 def post(self):
     if not self.user:
         self.redirect("/")
     title = self.request.get('title')
     if title:
         set_fetch_timeout(60000)
         urlfetch.set_default_fetch_deadline(60000)
         search = check_cache(title)
         if search:
             rating = search[0][1]
             blurb = search[1]
             film = Film(parent=film_key(),
                         title=title,
                         rating=rating,
                         blurb=blurb)
             film.put()
             top_films(True)
             self.redirect('/')
         else:
             error = 'not found'
             self.render("newmyfilm.html", title=title, error=error)
     else:
         error = "darf"
         self.render("newmyfilm.html", title=title, error=error)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)