def showProfile(self, id): query = meta.Session.query(model.User) c.show_user = query.filter(model.User.id == id).first() if not c.show_user: abort(404) c.title = c.show_user.name if c.user and int(c.user.id) == int(id): return render('/users/edit.mako') else: return render('/users/detail.mako') return _("That should not happen.")
def show(self, id): if id == '0': return redirect(url(controller='statements', action='index')) query = meta.Session.query(model.Statement) c.thesis = query.filter_by(id=id).first().attachTrueFalseCount() c.title = c.thesis c.feeds = [{'title': _('Arguments for this thesis'), 'link': config['base_url'] + h.url_for(controller='rss', action='showLastStatementsAsRssByStatement')}] if not c.thesis: abort(404) if c.thesis.parentid != 0: c.parentthesis = query.filter_by(id=c.thesis.parentid).first() c.trueArguments = query.filter_by(parentid=id,istrue=1).order_by(model.Statement.votes.desc()).all() for trueArgument in c.trueArguments: trueArgument.attachTrueFalseCount() c.falseArguments = query.filter_by(parentid=id,istrue=0).order_by(model.Statement.votes.desc()).all() for falseArgument in c.falseArguments: falseArgument.attachTrueFalseCount() return render('/statements/list-arguments.mako')
def newThesis(self): if not c.user: session['returnTo'] = {'controller': 'statements', 'action': 'newThesis'} session.save() redirect(url(controller='login', action='signin')) c.title = _("New Thesis") return render('/statements/new-thesis.mako')
def index(self): query = meta.Session.query(model.Statement) #rs = query.filter_by(parentid=None).select() c.thesis = query.filter_by(parentid=None).order_by(model.Statement.votes.desc()).all() if c.thesis: for aThesis in c.thesis: aThesis.attachTrueFalseCount() return render('/statements/list-thesis.mako')
def showUsersList(self): users_q = meta.Session.query(model.User) c.users = users_q.all() c.links = [ ('James','http://jimmyg.org'), ('Ben','http://groovie.org'), ('Philip',''), ] return render('/users/list.mako')
def edit_statement(self, id): if not c.user: session['returnTo'] = {'controller': 'statements', 'action': 'edit_statement', 'id': id} session.save() redirect(url(controller='login', action='signin')) query = meta.Session.query(model.Statement) c.statement = query.filter_by(id=id).first() if c.statement.parentid and c.statement.parentid != 0: c.thesis = query.filter_by(id=c.statement.parentid).first() c.thesisid = c.statement.parentid if c.thesis.parentid and c.thesis.parentid != 0: c.parentthesis = query.filter_by(id=c.thesis.parentid).first() return render('/statements/edit_statement.mako')
def search(self): search_query = request.params.get('query', None) if not search_query: abort(500) query = meta.Session.query(model.Statement) results = [] for result in search.search(search_query): statement = query.filter_by(id=result['id']).first() if statement: results.append(statement) c.results = results c.query = search_query return render('/search/search.mako')
def newArgument(self, id, istrue): if not c.user: session['returnTo'] = {'controller': 'statements', 'action': 'newArgument', 'id': id, 'istrue': istrue} session.save() redirect(url(controller='login', action='signin')) query = meta.Session.query(model.Statement) c.thesis = query.filter_by(id=id).first() c.thesisid=id if c.thesis.parentid != 0: c.parentthesis = query.filter_by(id=c.thesis.parentid).first() if istrue == "pro": c.istrue = True elif istrue == "contra": c.istrue = False else: abort(404) return render('/statements/new-argument.mako')
def faq(self): c.title = _("Frequently Asked Questions") return render('/pages/about.mako')
def about(self): c.title = _("What's going on?") return render('/pages/about.mako')
def config(self): c.statement_length = config['statement_length'] return render('js/config.mako')