Exemplo n.º 1
0
 def post(self):
     photo_id = int(self.request.get('pid'))
     Author = self.request.get('comment-name')
     comment = self.request.get('comment')
     photo = Image.get_Detail(photo_id)
     logging.error("Author is" + Author)
     logging.error(comment)
     if Author == '' or comment == '':
         pic_id = "/Home#" + str(photo_id)
         self.redirect(pic_id)
     else:
         if photo:
             try:
                 comment = Comment(
                     Author=Author,
                     Comment=comment, Image=photo.key)
                 comment.put()
                 logging.info("Horray, a comment is saved.")
             except:
                 logging.error("Error saving comment in datastore.")
             finally:
                 pic_id = "/Home#" + str(photo_id)
                 render = template.render('templates/redirect.html',
                                          {'link': pic_id, 'message': 'Commented'})
                 self.response.write(render)
Exemplo n.º 2
0
 def post(self):
     photo_id = int(self.request.get('pid'))
     photo = Image.get_Detail(photo_id)
     if photo:
         try:
             photo.Like = photo.Like + 1
             photo.put()
         except:
             logging.error("Error saving Like in datastore.")
         finally:
             pic_id = "/Home#" + str(photo_id)
             render = template.render('templates/redirect.html',
                                      {'link': pic_id, 'message': 'Liked'})
             self.response.write(render)