Пример #1
0
def render_mako(url, collection):
    tmap = { 'single': 'view_episodes_by_season.mako',
             'all': 'view_all_series.mako',
             'suggestions': 'view_episode_suggestions.mako'
             }

    t = get_mako_template('series', tmap, url.viewType)

    if url.viewType == 'single':
        # FIXME: this definitely doesn't belong here...
        try:
            config = collection.find_one(Config)
        except ValueError:
            config = collection.Config(displaySynopsis = True)

        series = collection.find_one(Series, title=url.args['title'])
        data = { 'title': series.title,
                 'series': series,
                 'displaySynopsis': config.displaySynopsis }

    elif url.viewType == 'all':
        data = { 'title': 'SERIES',
                 'series': collection.find_all(Series) }

    elif url.viewType == 'suggestions':
        data = { 'title': 'SUGGESTIONS',
                 'episodes': [ ep for ep in collection.find_all(Episode) if 'lastViewed' in ep ] }

    else:
        raise SmewtException('Invalid view type: %s' % url.viewType)

    data['url'] = url
    return t.render_unicode(**data)
Пример #2
0
def render_mako(url, collection):
    tmap = { 'speeddial': 'speeddial.mako'
             }

    t = get_mako_template('speeddial', tmap, 'speeddial')

    return t.render_unicode(title='SPEED DIAL',
                            url=url)
Пример #3
0
def render_mako(url, collection):
    tmap = { 'single': 'view_movie.mako',
             'all': 'view_all_movies.mako',
             'spreadsheet': 'view_movies_spreadsheet.mako',
             'unwatched': 'view_movies_spreadsheet.mako',
             'recent': 'view_recent_movies.mako'
             }

    t = get_mako_template('movie', tmap, url.viewType)

    if url.viewType == 'single':
        movie = collection.find_one(Movie, title = url.args['title'])
        data = { 'title': movie.title,
                 'movie': movie }

    elif url.viewType == 'all':
        data = { 'title': 'MOVIES',
                 'movies': collection.find_all(Movie) }

    elif url.viewType == 'spreadsheet':
        data = { 'title': 'MOVIE LIST',
                 'movies': collection.find_all(Movie) }

    elif url.viewType == 'unwatched':
        data = { 'movies': [ m for m in collection.find_all(node_type = Movie)
                             if not m.get('watched') and not m.get('lastViewed') ],
                 'title': 'UNWATCHED' }

    elif url.viewType == 'recent':
        data = { 'movies': [ m for m in collection.find_all(node_type = Movie)
                             if m.get('lastViewed') is not None ],
                 'title': 'RECENT' }

    else:
        raise SmewtException('Invalid view type: %s' % url.viewType)

    data['url'] = url
    return t.render_unicode(**data)