Example #1
0
   def post(self):

      user = users.get_current_user()
      user_info = models.UserInfo.get_by_key_name(user.user_id())
      if not user or user_info is None:
         self.redirect("/")

      path = self.request.get('path')

      # Instantiate content.
      content = models.UserContent(parent=models.thread_key(path))
      content.author = user
      content.display_name = user_info.display_name
      content.content = self.request.get('content')

      is_crocodoc_iframe = self.request.get('crocodoc', False)
      if is_crocodoc_iframe:
         if user_is_admin(user):
            content.is_crocodoc_iframe = True
         else:
            # Cheating??
            self.redirect("/")

      # Save and reload.
      content.put()
      self.redirect('/threads/' + path)
Example #2
0
   def get(self, path):

      if not thread_is_open(path):
         self.response.out.write(
            hard_html_serve.render_template('404.html')
         )
         return

      user = users.get_current_user()
      if not user:
         # User not logged in... Back to square 1.
         self.redirect("/")
         return

      # Check if user is known.
      if models.UserInfo.get_by_key_name(user.user_id()) is None:
         self.redirect("/signin.html")
         return

      # Query all user comments for that page.
      query = models.UserContent.all().ancestor(
          models.thread_key(path)).order('pubdate')
      contents = query.fetch(100)

      template_vals = {
         'page_title': path,
         'usercontents': contents,
         'path': path,
         'user_is_admin': user_is_admin(user),
      }

      self.response.out.write(
          hard_html_serve.render_template(path, template_vals)
      )