Ejemplo n.º 1
0
 def manage(self,type,id):
     if type == 'article':
         c.articles = Session.query(Article).order_by(desc(Article.pub_date)).all()
         return render('/admin/manage_news.html')
     elif type == 'comments':
         c.article = Session.query(Article).filter_by(id=id).order_by(desc(Article.pub_date)).one()
         return render('/admin/manage_comments.html')
Ejemplo n.º 2
0
 def _resolve_page(self):
     self._comments()
     c.comment_id = c.article.id
     c.comment_slug = c.article.slug
     c.modelcomment = ModelTags(None)
     if session.get('form_errors'):
         c.form_errors = session.get('form_errors')
         del session['form_errors']
         c.modelcomment = ModelTags(session.get('com_object'))
         del session['com_object']
         session.save()
     if 'partial' in request.params:
         return render('/comment_list.html')
     else:
         return render('/news.html')
Ejemplo n.º 3
0
    def add(self, type, id):
        schema = CommentForm()
        ret = self.__validate_obj(type, id)
        if ret:
            return "Failure %s" % ret
            
        try: 
            form_result = schema.to_python(request.params)
        except formencode.validators.Invalid, error:
            com = Comment(user=error.value['user'], email=error.value['email'],
                          content=error.value['content'], website=error.value['website'])
            if 'partial' in request.params:
                c.form_result = error.value
                c.form_errors = error.error_dict or {}
                c.modelcomment = ModelTags(com)
                return render('/comment-form.html')
            else:            
                d = {}
                for key,error in error.error_dict.items():
                    d[key] = error.msg
                session['com_object'] = com
                session['form_errors'] = d
                session.save()
#                log.info(session)
                redirect(self.__com_url(type, id, 'comment-form-section'))
Ejemplo n.º 4
0
 def index(self):
     c.races = Session.query(Race).order_by(desc(Race.id)).all()
     tmp = {}
     for r in c.races:
         tmp[r.id] = r
     c.jsonrace = json.dumps(tmp, cls=raceEncode)
     return render('/resources/char_create_index.html');
Ejemplo n.º 5
0
 def index(self):
     c.articleModel = ModelTags(None)
     if session.get('form_errors'):
         c.form_errors = session.get('form_errors')
         del session['form_errors']
         c.articleModel = ModelTags(session.get('new_article'))
         del session['new_article']
         session.save()
     return render('/admin/post_news.html')
Ejemplo n.º 6
0
 def login(self):
     """
     This is where the login form will be rendered
     The login counter will tell if the user has tried to login
     with the wrong credentials
     """
     identity = request.environ.get('repoze.who.identity')
     came_from = str(request.GET.get('came_from', '')) or \
                 url(controller='account', action='welcome')
     if identity:
         redirect(url(came_from))
     else:
         c.came_from = came_from
         c.login_counter = request.environ['repoze.who.logins'] + 1
         if c.login_counter > 1:
             flash('Incorrect Username or Password','error')
         return render('/login.html')
Ejemplo n.º 7
0
 def index(self):
     c.articles = self.news_q.order_by(desc(Article.pub_date)).all()
     return render('/news_index.html')
Ejemplo n.º 8
0
 def index(self):
     # Return a rendered template
     #return render('/news.mako')
     # or, return a string
     return render('/index.html')
Ejemplo n.º 9
0
                c.form_result = error.value
                c.form_errors = error.error_dict or {}
                c.modelcomment = ModelTags(com)
                return render('/comment-form.html')
            else:            
                d = {}
                for key,error in error.error_dict.items():
                    d[key] = error.msg
                session['com_object'] = com
                session['form_errors'] = d
                session.save()
#                log.info(session)
                redirect(self.__com_url(type, id, 'comment-form-section'))
        else:
            com = Comment(user=form_result['user'],email=form_result['email'],
                        website=form_result['website'],content=form_result['content'], 
                        type=type,ip_addr=request.environ.get('REMOTE_ADDR'))
            if type == 'article':
                com.article_id = id
            Session.add(com)
            Session.commit()
            
            anchor = 'comments'
            if 'partial' in request.params:
                c.link_url = self.__com_url(type, id, anchor)
                c.partial_url = self.__com_url(type, id, anchor, True)
                return render('/refresh_comments.html')
            else:
                redirect(self.__com_url(type, id, anchor))