def list(catname, page=1): cat_id = catname2id.get(catname) if not cat_id: abort(404) page = int(page) perpage = 100 artist_work_url = artist_work_url_func(catname) artist_id = request.args.get('artist', '') artist_id = int(artist_id) if artist_id.isdigit() else None artist = Artist.get(artist_id) query = Work.query.filter(Work.cat == cat_id).order_by(Work.pubdate.desc()) if artist_id: query = query.filter(Work.artist_id == artist_id) def artist_work_url(artist): args = dict(catname=catname) if artist_id != artist.id: args['artist'] = artist.id return url_for('works.list', **args) pagination = query.paginate(page, perpage) items = pagination.items years = sorted(set(x.pubdate.year for x in items), reverse=True) return st('/modules/works/%s/index.html' % catname, **locals())
def home(): articles, captions = get_homepage_articles() articles = [x.extended_self() for x in articles] carousel_items = [dict(img=x.picture_url('large'), link=x.url(), caption=captions[i]) for i,x in enumerate(articles) if x] return st('modules/pages/home.html', **locals())
def news_list(page=1): limit = perpage = 5 pagi = News.query.order_by(News.create_at.desc()).paginate(page, perpage) items = pagi.items total = pagi.total Catname = 'News' endpoint = 'news.news_list' return st('/modules/news/index.html', **locals())
def show(uid): work = Work.get_or_404(uid) audios, videos = work.attachment_medias() carousel_items = [dict(img=a.url(), caption=a.desc) for a in work.attachment_pics()] cat = work.cat_name artist = work.artist artist_work_url = artist_work_url_func(work.cat_name) return st('/modules/works/%s/show.html' % cat, **locals())
def show(page): if '.' in page: return current_app.send_static_file(page) if page == 'show' or page.isdigit(): return abort(404) try: return st('modules/pages/%s.html' % page) except TemplateNotFound, e: pass
def charity_single(uid): article = Charity.get_or_404(uid) pics = article.attachment_pics() return st('/modules/news/show.html', **locals())
def list(page=1): perpage = 40 pagi = Event.query.order_by(Event.create_at.desc()).paginate(page, perpage) data = list_data(pagi) return st('/modules/event/index.html', **locals())
# -*- coding: utf-8 -*- from flask import Blueprint, abort, redirect, request as req from flask import current_app from david.lib.template import TemplateNotFound, st from .model import Page bp = Blueprint('pages', __name__) @bp.route('/<page>') def show(page): if '.' in page: return current_app.send_static_file(page) if page == 'show' or page.isdigit(): return abort(404) try: return st('modules/pages/%s.html' % page) except TemplateNotFound, e: pass item = Page.get_or_404(page) return st('modules/pages/show.html', **locals()) __all__ = [bp]
def show(ident): endpoint = 'gallery.magazine' cls = Magazine item = cls.get_or_404(ident) carousel_items = [dict(img=x['large_url'], caption=x['desc']) for x in item.pics_info()] return st('modules/gallery/show.html', **locals())
def magazine_home(): data = list_data(mod='magazine', page=1) return st('modules/gallery/magazine.html', **locals())
def home(): return redirect(url_for('works.list', catname='movie')) return st('/modules/works/index.html', **locals())
def f(e): status_code = code if isinstance(code, int) else 500 if request.is_xhr: return jsonify({ 'r': status_code }) return st('errors/%s.html' % code), status_code
def detail(uid): artist = Artist.get_or_404(uid) return st('modules/artist/detailed.html', **locals())
def intro(uid): artist = Artist.get_or_404(uid) return st('modules/artist/show.html', **locals())