Esempio n. 1
0
 def get(self, key):
     try:
         comment = Comment.get(db.Key(key))
     except(Exception):
         comment = None
     if comment:
         template_values = {
             'comment': comment,
             }
         path = os.path.join(os.path.dirname(__file__), '..', 'view', 'comment/index.html')
         result = template.render(path, template_values)
     else:
         path = os.path.join(os.path.dirname(__file__), '..', 'view', 'comment/not_found.html')
         result = template.render(path, {})
     self.response.out.write(result)
Esempio n. 2
0
 def post(self):
     media=self.getMedia(self.request.get('key'))
     if media:
         comment=Comment()
         comment.title=self.request.get('title')
         u=users.get_current_user()
         if u:
             comment.by=u.nickname()
         else:
             comment.by="Mr. I'm too good to log in"
         comment.text=self.request.get('text')
         commentkey=self.request.get('commentkey')
         if commentkey:
             comment.op=Comment.get(commentkey)
         else:
             comment.media=media
         comment.put()
             
         template_values = {"media":media}
         path = os.path.join(os.path.dirname(__file__), '../html/details.html')
         shared.render(self, path, template_values)
Esempio n. 3
0
 def delete(self, key):
     comment = Comment.get(db.Key(key))
     user = users.get_current_user()
     if comment and user and user == comment.author:
         comment.delete()
         self.response.out.write("ok")
Esempio n. 4
0
 def show(self):
     r = Comment.get(self.params.get('id'))