Esempio n. 1
0
File: news.py Progetto: syhw/hnewsfr
 def get(self):
     e = data.Post.get_by_id(int(self.request.get('for')))
     if (data.user_found(users.get_current_user(), e.key())):
         return -1
     v = data.Up()
     v.voter = users.get_current_user()
     v.entry = e
     v.put()
     e.ups = e.ups + 1
     e.put()
     if (e.__class__.__name__ == "Post"):
         data.update_ranks()
     else:
         data.update_comments()
Esempio n. 2
0
File: news.py Progetto: syhw/hnewsfr
 def get(self):
     post = data.Post.get_by_id(int(self.request.get('pid')))
     if users.get_current_user() is None:
         url = users.create_login_url(self.request.uri)
         url_linktext = 'Login'
         template_values = {
                 'post': data.DisplayPost(post, None),
                 'url': url,
                 'url_linktext': url_linktext,
                 'comments': data.DisplayComments(post.get_comments(), None),
                 'view': 0
                 }
     else:
         u = users.get_current_user()
         template_values = {
                 'post': data.DisplayPost(post, u),
                 'comments': data.DisplayComments(post.get_comments(), u),
                 'view': 1 - data.user_found(u, post.key())
                 }
     path = os.path.join(os.path.dirname(__file__), 'comment.html')
     self.response.out.write(template.render(path, template_values))