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 __get_rss__(query): myItems = [] for theArgument in query[:11]: if not theArgument.parentid: argument_title = _("New Thesis") elif theArgument.istrue == 1: argument_title = _("New Pro-Argument for: ") + markup.stripMarkupAndTruncate(theArgument.get_parent_thesis().message)[:50] else: argument_title = _("New Contra-Argument for: ") + markup.stripMarkupAndTruncate(theArgument.get_parent_thesis().message)[:50] newItem = PyRSS2Gen.RSSItem( title = argument_title, link = config['base_url'] + h.url_for(controller='statements', action='show', id=str(theArgument.id)), description = markup.renderMarkup(theArgument.message), guid = PyRSS2Gen.Guid(str(theArgument.id), False), #entry['guidislink'] pubDate = theArgument.created) myItems.append(newItem) rss = PyRSS2Gen.RSS2( title = _("the Truth: Latest Statements"), link = config['base_url'], description = _("The latest statements from the Truth (tm)"), lastBuildDate = datetime.now(), items = myItems) return rss.to_xml("utf-8")
def newUsersRss(self): query = meta.Session.query(model.User).order_by(model.User.signup.desc()) myItems = [] for it in query.all(): newItem = PyRSS2Gen.RSSItem( title = it.getDisplayName(), link = config['base_url'] + h.url_for(action='showProfile', id=str(it.id)), description = it.getDisplayName(), guid = PyRSS2Gen.Guid(str(it.id), False), #entry['guidislink'] pubDate = it.signup) myItems.append(newItem) rss = PyRSS2Gen.RSS2( title = _("the Truth: Latest Users"), link = config['base_url'], description = _("Latest users joining Truth (tm)"), lastBuildDate = datetime.now(), items = myItems) return rss.to_xml()