Exemple #1
0
 def post(self):
     k = self.request.get("entity_key")
     if k:
         # if edit
         movie_key = ndb.Key(urlsafe=k)
         movie = movie_key.get()
         movie.title = self.request.get("input-title")
         movie.category = self.request.get_all("input-category")
         movie.length = int(self.request.get("input-length"))
         movie.rating = int(self.request.get("input-rating"))
         movie.show_type = self.request.get("input-type")
         movie.put()
     else:
         #if add
         
         #get the values of the elements whose name="value"
         title = self.request.get("input-title")
         category = self.request.get_all("input-category")
         length = int(self.request.get("input-length"))
         rating = int(self.request.get("input-rating"))
         show_type = self.request.get("input-type")
         
         #create an object
         new_movie_entry = MovieEntry(parent=PARENT_KEY,
                                      title = title,
                                      category = category,
                                      length = length,
                                      rating = rating,
                                      show_type = show_type
                                      )
         #save it to the datastore
         new_movie_entry.put()
         
     #redirect
     self.redirect(self.request.referer)
Exemple #2
0
 def get(self):
     movie_entry_query = MovieEntry.query(ancestor=PARENT_KEY).order(-MovieEntry.last_touch_date_time)
     template = jinja_env.get_template("templates/home.html")
     self.response.write(template.render({"movie_entry_query": movie_entry_query
                                          }))