def view(self, slug, page=1, show='latest', **kwargs): """View a podcast and the media that belongs to it. :param slug: A :attr:`~mediacore.model.podcasts.Podcast.slug` :param page: Page number, defaults to 1. :type page: int :rtype: dict :returns: podcast A :class:`~mediacore.model.podcasts.Podcast` instance. episodes A list of :class:`~mediacore.model.media.Media` instances that belong to the ``podcast``. podcasts A list of all the other podcasts """ podcast = fetch_row(Podcast, slug=slug) episodes = podcast.media.published() episodes, show = helpers.filter_library_controls(episodes, show) return dict( podcast = podcast, episodes = episodes, result_count = episodes.count(), show = show, )
def view(self, slug, page=1, show='latest', **kwargs): """View a podcast and the media that belongs to it. :param slug: A :attr:`~mediacore.model.podcasts.Podcast.slug` :param page: Page number, defaults to 1. :type page: int :rtype: dict :returns: podcast A :class:`~mediacore.model.podcasts.Podcast` instance. episodes A list of :class:`~mediacore.model.media.Media` instances that belong to the ``podcast``. podcasts A list of all the other podcasts """ podcast = fetch_row(Podcast, slug=slug) episodes = podcast.media.published() episodes, show = helpers.filter_library_controls(episodes, show) episodes = viewable_media(episodes) if request.settings['rss_display'] == 'True': response.feed_links.append( (url_for(action='feed'), podcast.title) ) return dict( podcast = podcast, episodes = episodes, result_count = episodes.count(), show = show, )
def view(self, slug, page=1, show='latest', **kwargs): """View a podcast and the media that belongs to it. :param slug: A :attr:`~mediacore.model.podcasts.Podcast.slug` :param page: Page number, defaults to 1. :type page: int :rtype: dict :returns: podcast A :class:`~mediacore.model.podcasts.Podcast` instance. episodes A list of :class:`~mediacore.model.media.Media` instances that belong to the ``podcast``. podcasts A list of all the other podcasts """ podcast = fetch_row(Podcast, slug=slug) episodes = podcast.media.published() episodes, show = helpers.filter_library_controls(episodes, show) episodes = viewable_media(episodes) return dict( podcast=podcast, episodes=episodes, result_count=episodes.count(), show=show, )
def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediacore.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published() media, show = helpers.filter_library_controls(media, show) if q: media = media.search(q, bool=True) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) if (request.settings['rss_display'] == 'True') and (not (q or tag)): if show == 'latest': response.feed_links.extend([ (url_for(controller='/sitemaps', action='latest'), u'Latest RSS'), ]) elif show == 'featured': response.feed_links.extend([ (url_for(controller='/sitemaps', action='featured'), u'Featured RSS'), ]) media = viewable_media(media) return dict( media=media, result_count=media.count(), search_query=q, show=show, tag=tag, )
def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediacore.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published() media, show = helpers.filter_library_controls(media, show) if q: media = media.search(q, bool=True) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) if (request.settings['rss_display'] == 'True') and (not (q or tag)): if show == 'latest': response.feed_links.extend([ (url_for(controller='/sitemaps', action='latest'), u'Latest RSS'), ]) elif show == 'featured': response.feed_links.extend([ (url_for(controller='/sitemaps', action='featured'), u'Featured RSS'), ]) media = viewable_media(media) return dict( media = media, result_count = media.count(), search_query = q, show = show, tag = tag, )
def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediacore.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published()\ .options(orm.undefer('comment_count_published')) media, show = helpers.filter_library_controls(media, show) if q: search = media.search(q, bool=True) if search.count(): media = search else: media = media.filter(Media.title.like("%%%s%%" % q)) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) return dict( media = media, result_count = media.count(), search_query = q, show = show, tag = tag, )
def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediacore.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published() media, show = helpers.filter_library_controls(media, show) if q: media = media.search(q, bool=True) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) userid = request.environ['repoze.who.identity']['repoze.who.userid'] if userid == 'guest': redirect(controller='/login', action='logout_handler') return dict( media = media, result_count = media.count(), search_query = q, show = show, tag = tag, userid =userid, )
def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediacore.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published() media, show = helpers.filter_library_controls(media, show) if q: media = media.search(q, bool=True) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) return dict( media=media, result_count=media.count(), search_query=q, show=show, tag=tag, )