Exemplo n.º 1
0
  def post(self, post_id):
    session = get_current_session()
    title = helper.sanitizeHtml(self.request.get('title'))
    message = helper.sanitizeHtml(self.request.get('message'))

    if session.has_key('user'):
      user = session['user']
      try:
        post = db.get(helper.parse_post_id(post_id))
        if post.can_edit():
          if len(title) > 0:
            post.title = title
          if post.message is not None and message is not None:
            post.message = message
          post.edited = True
          post.put()
	  
	  #index with indextank
	  helper.indextank_document(helper.base_url(self), post)

	  self.redirect('/noticia/' + str(post.key()))
        else:
          self.redirect('/')
      except db.BadKeyError:
        self.redirect('/')  
    else:
      self.redirect('/')
Exemplo n.º 2
0
    def post(self, post_id):
        session = get_current_session()
        title = helper.sanitizeHtml(self.request.get('title'))
        message = helper.sanitizeHtml(self.request.get('message'))

        if session.has_key('user'):
            user = session['user']
            try:
                post = db.get(helper.parse_post_id(post_id))
                if post.can_edit():
                    if len(title) > 0:
                        post.title = title
                    if post.message is not None and message is not None:
                        post.message = message
                    post.edited = True
                    post.put()

                    #index with indextank
                    helper.indextank_document(helper.base_url(self), post)

                    self.redirect('/noticia/' + str(post.key()))
                else:
                    self.redirect('/')
            except db.BadKeyError:
                self.redirect('/')
        else:
            self.redirect('/')
  def post(self):
    session = get_current_session()
    url = self.request.get('url')
    title = helper.sanitizeHtml(self.request.get('title'))
    message = helper.sanitizeHtml(self.request.get('message'))
    nice_url = helper.sluglify(title)
    
    if session.has_key('user'):
      if len(nice_url) > 0:
        user = session['user']
        if len(message) == 0: #is it a post or a message?
          #Check that we don't have the same URL within the last 'check_days'
          since_date = date.today() - timedelta(days=7)
          q = Post.all().filter("created >", since_date).filter("url =", url).count()
          url_exists = q > 0
          q = Post.all().filter("nice_url", nice_url).count()
          nice_url_exist = q > 0
          try:
            if not url_exists:
              if not nice_url_exist:
                post = Post(url=url,title=title,message=message, user=user, nice_url=nice_url)
                post.put()
                helper.killmetrics("Submit","Link", "do", session, "",self)
                vote = Vote(user=user, post=post, target_user=post.user)
                vote.put()
                Post.remove_cached_count_from_memcache()
 	
                #index with indextank
                helper.indextank_document( helper.base_url(self), post)
                
                self.redirect('/noticia/' + str(post.nice_url));
              else:
                session['post_error'] = "Este titulo ha sido usado en una noticia anterior"
                self.redirect('/agregar')
            else:
              session['post_error'] = "Este link ha sido entregado en los ultimo 7 dias"
              self.redirect('/agregar')
          except db.BadValueError:
            session['post_error'] = "El formato del link no es valido"
            self.redirect('/agregar')
        else:
          q = Post.all().filter("nice_url", nice_url).count()
          nice_url_exist = q > 0
          if not nice_url_exist:
            post = Post(title=title,message=message, user=user, nice_url=nice_url)
            post.put()
            helper.killmetrics("Submit","Post", "do", session, "",self)
            post.url = helper.base_url(self) + "/noticia/" + post.nice_url
            post.put()
            Post.remove_cached_count_from_memcache()
            vote = Vote(user=user, post=post, target_user=post.user)
            vote.put()

	    #index with indextank
	    helper.indextank_document( helper.base_url(self), post)
            
	    self.redirect('/noticia/' + post.nice_url);
          else:
            session['post_error'] = "Este titulo ha sido usado en una noticia anterior"
            self.redirect('/agregar')
      else:
        session['post_error'] = "Necesitas agregar un titulo"
        self.redirect('/agregar')
    else:
      self.redirect('/login')
Exemplo n.º 4
0
 def post(self):
   post = db.get(self.request.get('post_key'))
   base_url = self.request.get('base_url')
   helper.indextank_document(base_url, post) 
    def post(self):
        session = get_current_session()
        url = self.request.get('url')
        title = helper.sanitizeHtml(self.request.get('title'))
        message = helper.sanitizeHtml(self.request.get('message'))
        nice_url = helper.sluglify(title)

        if session.has_key('user'):
            if len(nice_url) > 0:
                user = session['user']
                if len(message) == 0:  #is it a post or a message?
                    #Check that we don't have the same URL within the last 'check_days'
                    since_date = date.today() - timedelta(days=7)
                    q = Post.all().filter("created >",
                                          since_date).filter("url =",
                                                             url).count()
                    url_exists = q > 0
                    q = Post.all().filter("nice_url", nice_url).count()
                    nice_url_exist = q > 0
                    try:
                        if not url_exists:
                            if not nice_url_exist:
                                post = Post(url=url,
                                            title=title,
                                            message=message,
                                            user=user,
                                            nice_url=nice_url)
                                post.put()
                                helper.killmetrics("Submit", "Link", "do",
                                                   session, "", self)
                                vote = Vote(user=user,
                                            post=post,
                                            target_user=post.user)
                                vote.put()
                                Post.remove_cached_count_from_memcache()

                                #index with indextank
                                helper.indextank_document(
                                    helper.base_url(self), post)

                                self.redirect('/noticia/' + str(post.nice_url))
                            else:
                                session[
                                    'post_error'] = "Este titulo ha sido usado en una noticia anterior"
                                self.redirect('/agregar')
                        else:
                            session[
                                'post_error'] = "Este link ha sido entregado en los ultimo 7 dias"
                            self.redirect('/agregar')
                    except db.BadValueError:
                        session[
                            'post_error'] = "El formato del link no es valido"
                        self.redirect('/agregar')
                else:
                    q = Post.all().filter("nice_url", nice_url).count()
                    nice_url_exist = q > 0
                    if not nice_url_exist:
                        post = Post(title=title,
                                    message=message,
                                    user=user,
                                    nice_url=nice_url)
                        post.put()
                        helper.killmetrics("Submit", "Post", "do", session, "",
                                           self)
                        post.url = helper.base_url(
                            self) + "/noticia/" + post.nice_url
                        post.put()
                        Post.remove_cached_count_from_memcache()
                        vote = Vote(user=user,
                                    post=post,
                                    target_user=post.user)
                        vote.put()

                        #index with indextank
                        helper.indextank_document(helper.base_url(self), post)

                        self.redirect('/noticia/' + post.nice_url)
                    else:
                        session[
                            'post_error'] = "Este titulo ha sido usado en una noticia anterior"
                        self.redirect('/agregar')
            else:
                session['post_error'] = "Necesitas agregar un titulo"
                self.redirect('/agregar')
        else:
            self.redirect('/login')
Exemplo n.º 6
0
 def post(self):
     post = db.get(self.request.get('post_key'))
     base_url = self.request.get('base_url')
     helper.indextank_document(base_url, post)