def by_tag(request, tag, *args, **kwargs): """Post listing. Only shows posts that are older than now() and belongs to specified tags""" queryset = Post.objects.filter(date__lte=dt.now()) if not kwargs.has_key('extra_context'): kwargs['extra_context'] = {} kwargs['extra_context']['feedurl'] = 'tag/%s' % tag if '+' in tag: return tagged_object_list(request, queryset, tag.split('+'), union=False, *args, **kwargs) else: return tagged_object_list(request, queryset, tag.split('|'), *args, **kwargs)
def dehex_tagged_object_list(request, queryset_or_model=None, tag=None, related_tags=False, related_tag_counts=True): dehexed = tag.decode('hex') return tagged_object_list(request=request, queryset_or_model=queryset_or_model, tag=dehexed, related_tags=related_tags, related_tag_counts=related_tag_counts)
def show_tagged_links_object_list(request, username, spacename, tag): """ This view gives you the links that have been marked with the ``tag`` **Type:** * public **Arguments:** * request: Request object * username: string containing the username * spacename: name of the space that you want to watch * tag: tag to consult **Template:** * ``coltrane/entry_detail.html`` **Decorators:** None """ l = Link.objects.filter(posted_by__username=username).filter(space__slug=spacename) #l.filter(tags__icontains=tag) tags = Tag.objects.select_related(depth=2).get(id=tag) return tagged_object_list(request, #queryset_or_model=l.filter(tags__icontains=tag), queryset_or_model=l.filter(tags__icontains=tags.name), tag = tags.name, related_tags = False, template_name='coltrane/links_by_tags.html', extra_context={'username': username, 'spacename': spacename, })
def blog_archive_tagged(request, **kwargs): blog_slug = kwargs.pop('blog_slug') kwargs['queryset_or_model'] = (kwargs['queryset_or_model'].published() .filter(blog__slug=blog_slug)) set_language_changer(request, language_changer) return tagged_object_list(request, extra_context={ 'blog_slug': blog_slug }, **kwargs)
def tagged_entry_list(request, *args, **kwargs): """ A thin wrapper around ``tagging.views.tagged_object_list``. """ if 'queryset_or_model' not in kwargs: kwargs['queryset_or_model'] = Entry.published_on_site.all() return tagged_object_list(request, *args, **kwargs)
def tag_detail(request, slug, template_name='blog/tag_detail.html', **kwargs): return tagged_object_list( request, queryset_or_model=Entry.objects.published_for_list(), tag=slug, template_name=template_name, **kwargs)
def tag_detail(request, slug, template_name = 'blog/tag_detail.html', **kwargs): return tagged_object_list( request, queryset_or_model = Entry.objects.published_for_list(), tag = slug, template_name = template_name, **kwargs )
def tag_archive(request, tag): qs = Project.objects.select_related() if hasattr(qs, '_gatekeeper'): qs = qs.approved() return tagged_object_list(request, qs, tag, paginate_by=10, template_object_name='project', extra_context={'tag':tag}, allow_empty=True)
def blog_archive_tagged(request, **kwargs): blog_slug = kwargs.pop('blog_slug') kwargs['queryset_or_model'] = ( kwargs['queryset_or_model'].published().filter(blog__slug=blog_slug)) set_language_changer(request, language_changer) return tagged_object_list(request, extra_context={'blog_slug': blog_slug}, **kwargs)
def ideas_by_tag(request, tag): categories = Category.objects.all() cities = Idea.published.values_list('city').distinct() return tagged_object_list(tag, queryset_or_model=Idea, template_name='portfolio/ideas_by_tag.html', extra_context={'categories': categories, 'cities': cities,})
def tag(request, tag): return tagged_object_list( request, Post.objects.published().select_related(), tag, paginate_by=POSTS_PER_PAGE, template_object_name='post', extra_context={'tag': tag}, allow_empty=True)
def tag_detail(request, tag, page=None, **kwargs): """Display the entries of a tag""" if not kwargs.get('template_name'): kwargs['template_name'] = template_name_for_entry_queryset_filtered( 'tag', slugify(tag)) return tagged_object_list(request, tag=tag, queryset_or_model=Entry.published.all(), paginate_by=PAGINATION, page=page, **kwargs)
def tag_detail(request, tag, page=None): """Display the entries of a tag""" template_name = template_name_for_entry_queryset_filtered('tag', tag) return tagged_object_list(request, tag=tag, queryset_or_model=Entry.published.all(), paginate_by=PAGINATION, page=page, template_name=template_name)
def tag(request, tag): return tagged_object_list( request, Post.objects.published().select_related(), tag, paginate_by=POSTS_PER_PAGE, template_object_name='post', template_name='posts_lede.html', extra_context={'tag': tag}, allow_empty=True)
def articles_by_tag(request, *args, **kwargs): """Show articles matching selected tag""" from tagging.views import tagged_object_list kwargs.update({ 'template_object_name' : 'article', 'template_name' : 'articles/article_list.html', 'queryset_or_model' : Article.objects.published(), 'paginate_by': ARTICLES_PAGINATED_BY, 'page': request.GET.get('page', 1), }) return tagged_object_list(request, **kwargs)
def show_user_tags(request, username, tag=None): queryset = Event.objects.filter(author=request.user.id) if tag == None: return HttpResponseRedirect(reverse('index_lablog')) else: return tagged_object_list(request, queryset, tag, paginate_by=25, allow_empty=True, template_name='lablog/basic/tags.html')
def skill(request, tag): return tagged_object_list(request, model = DjangoPerson, tag = tag, related_tags = True, related_tag_counts = True, template_name = 'skill.html', extra_context = { 'api_key': settings.GOOGLE_MAPS_API_KEY, }, )
def bookmark_tag_detail(request, tag): queryset = Bookmark.shared_objects.all() return tagged_object_list( request, queryset, tag, paginate_by=10, allow_empty=True, template_object_name="bookmark", template_name="djangolicious/bookmark_list.html", )
def tag(request, tag): sort_order = request.GET.get('sort', 'created') queryset = Submission.objects.all_sorted(sort_order)\ .exclude(hidden=True) return tagged_object_list(request, queryset_or_model=queryset, tag=tag, paginate_by=DEMOS_PAGE_SIZE, allow_empty=True, template_loader=template_loader, template_object_name='submission', template_name='demos/listing_tag.html')
def tagged(request, tag): title = ugettext_lazy('Votes tagged %(tag)s') % {'tag': tag} try: return tagged_object_list(request, queryset_or_model=Vote, tag=tag, extra_context={'title': title}) except Http404: return object_list(request, queryset=Vote.objects.none(), extra_context={'title': title})
def tagged_entry_list(self, request, entry_queryset=None, *args, **kwargs): if entry_queryset is not None: queryset = entry_queryset else: queryset = self.entry_queryset info_dict = { 'queryset_or_model': queryset, 'template_name': '%s/tag_detail.html' % self.template_root_path, 'template_object_name': 'entry', } return tagged_object_list(request, *args, **dict(info_dict, **kwargs))
def tagged_links(request,tag): sort = request.GET.get('sort') queryset=None if sort in sort_by.keys(): queryset=Link.published.filter().order_by('%s' % sort_by[sort]) else: queryset=Link.published.filter().order_by('-total_votes') return tagged_object_list(request,queryset,tag,paginate_by=settings.RESULTS_PER_PAGE,allow_empty=True, template_object_name="object_list")
def get_queryset(self): """Выберем из БД все подходящие видео-файлы""" qs = super(SearchResultsView, self).get_queryset() query = self.kwargs.get('query') tag = self.validate_tag(query) if tag: object_list = tagged_object_list(self.request, qs, tag) return object_list qs = self.validate_video(qs, query) return qs
def country_skill(request, country_code, tag): return tagged_object_list(request, model = DjangoPerson, tag = tag, related_tags = True, related_tag_counts = True, extra_filter_args = {'country__iso_code': country_code.upper()}, template_name = 'skill.html', extra_context = { 'api_key': settings.GOOGLE_MAPS_API_KEY, 'country': Country.objects.get(iso_code = country_code.upper()), }, )
def tagged_entry_list(self, request, *args, **kwargs): if 'entry_queryset' in kwargs: queryset = kwargs['entry_queryset'] del kwargs['entry_queryset'] else: queryset = self.entry_queryset info_dict = { 'queryset_or_model': queryset, 'template_name': '%s/tag_detail.html' % self.template_root_path, 'template_object_name': 'entry', 'paginate_by': self.paginate_by, } return tagged_object_list(request, *args, **dict(info_dict, **kwargs))
def articles_by_tag(request, *args, **kwargs): """Show articles matching selected tag""" from tagging.views import tagged_object_list kwargs.update( { "template_object_name": "article", "template_name": "articles/article_list.html", "queryset_or_model": Article.objects.published(), "paginate_by": ARTICLES_PAGINATED_BY, "page": request.GET.get("page", 1), } ) return tagged_object_list(request, **kwargs)
def tag_detail(request, tag): return tagged_object_list(request, queryset_or_model=Entry.objects.all(), tag=tag, extra_context={ "month_list": Entry.objects.filter().dates( 'pub_date', 'month'), "category_list": Category.objects.all(), "tag_list": Tag.objects.all() }, template_name="DJPlus/tag_list.html")
def entries_tagged_with(request, tag, template_name="tags/entries_tagged_with.html"): params = { "queryset_or_model": get_latest_entries(), "tag": tag, "template_name": '%s/%s' % (settings.TEMPLATE_NAME, template_name), "paginate_by": settings.ENTRIES_PER_PAGE, "page": request.GET.get("page", 1), "template_object_name": "entry", # FIXME: the following line results as an AttributeError due to bug #179 # (http://code.google.com/p/django-tagging/issues/detail?id=179) # "related_tags": True, } return tagged_object_list(request, **params)
def tag_detail(request, slug, template_name = 'book/book_list.html', **kwargs): tag = str(slug).replace('-', ' ') kwargs = { 'template_name':template_name, 'paginate_by':10, 'extra_context':{'content_title':'Books tagged with <i>"'+tag+'"</i>'} } return tagged_object_list( request, Book.objects.published(), tag, **kwargs )
def show_bird_tags(request, tag=None): # show tag cloud if tag == None: mydict = { 'coupling_choices': Bird.COUPLING_CHOICES, } return direct_to_template(request, 'birdlist/basic/tag_cloud.html', mydict) # show list of animals matching tag or coupling status. else: # check if user is looking up a tag or a coupling status. coupling_query = False coupling_value = None for i in Bird.COUPLING_CHOICES: if tag == i[1]: coupling_query = True coupling_value = i[0] break # sort by coupling status if coupling_query == True: queryset = Bird.objects.filter(coupling_status=coupling_value) extra_context = { 'tag': tag, 'header_name': 'coupling status', } return object_list(request, queryset=queryset, paginate_by=25, template_name='birdlist/basic/tags.html', extra_context=extra_context) # sort by tag else: queryset = Bird.objects.all() extra_context = { 'header_name': 'tag', } return tagged_object_list(request, queryset, tag, paginate_by=25, extra_context=extra_context, allow_empty=True, template_name='birdlist/basic/tags.html')
def tagged_links(request, tag): sort = request.GET.get('sort') queryset = None if sort in sort_by.keys(): queryset = Link.published.filter().order_by('%s' % sort_by[sort]) else: queryset = Link.published.filter().order_by('-total_votes') return tagged_object_list(request, queryset, tag, paginate_by=settings.RESULTS_PER_PAGE, allow_empty=True, template_object_name="object_list")
def index(request): tag = "Finance Data Catalog" categories = Category.objects.all() return tagged_object_list( request, Post.objects.published().select_related(), tag, paginate_by=4, template_object_name='post', template_name='findatcat/index.html', extra_context={ 'tag': tag, 'categories': categories }, allow_empty=True, )
def list_tagged_entries(request, url_lang, url_profile, url_event, url_app, url_pg, **kwargs): context = PortalContext.context(request, url_lang, url_profile, url_event, url_app, url_pg, **kwargs) return tagged_object_list( request, queryset_or_model=Entry.objects.filter( Q(spam__isnull=True) | Q(spam=False)), #queryset_or_model = Entry, tag=kwargs['tag'], paginate_by=20, allow_empty=True, template_name='tagforum/entry_list.html', extra_context=context)
def tag_detail(request, tag): """ Renders the tag detail page """ return tagged_object_list( request, Post.objects, tag, paginate_by=5, page=request.GET.get("page", 1), allow_empty=True, template_name="blog/tag_detail.html", template_object_name="posts", extra_context={ "pager_url": make_url_pattern(reverse("blog_tag_detail", kwargs={"tag": tag}), request.GET), } )
def tag_archive(request, tag): """ Paginated listing of ``Project``s by tag. Template: projects/projects_list.html Context: tag - tag being displayed project_list - list of projects See ``django.views.generic.list_detail.object_list`` for pagination variables. """ qs = Project.objects.select_related() if hasattr(qs, '_gatekeeper'): qs = qs.approved() return tagged_object_list(request, qs, tag, paginate_by=10, template_object_name='project', extra_context={'tag':tag}, allow_empty=True)
def show_tagged_object_list(request, username, spacename, tag): """ This view gives you the entries that have been marked with the ``tag`` **Type:** * public **Arguments:** * request: Request object * username: string containing the username * spacename: name of the space that you want to watch * tag: tag to consult **Template:** * ``coltrane/entries_by_tag.html`` **Decorators:** None """ e = Entry.live.filter(space__slug=spacename).filter(author__username=username) tags = Tag.objects.select_related(depth=2).get(id=tag) # This comment want to leave because I have changed the template that it # renders, plus the url config file, so leave for now. #e.filter(tags__icontains=tag) return tagged_object_list(request, queryset_or_model=e.filter(tags__icontains=tags.name), # idem #e.filter(tags__icontains=tag), tag = tags.name, related_tags=False, template_name = 'coltrane/entries_by_tag.html', extra_context={'username': username, 'spacename': spacename, 'tags': e.filter(tags__icontains=tags.name), # idem #e.filter(tags__icontains=tag), },)
def tag_archive(request, tag): """ Paginated listing of ``Project``s by tag. Template: projects/projects_list.html Context: tag - tag being displayed project_list - list of projects See ``django.views.generic.list_detail.object_list`` for pagination variables. """ qs = Project.objects.select_related() if hasattr(qs, '_gatekeeper'): qs = qs.approved() return tagged_object_list(request, qs, tag, paginate_by=10, template_object_name='project', extra_context={'tag': tag}, allow_empty=True)
def entry_list(request, queryset=Entry.objects.order_by('add_date'), tag=None, template_object_name='entry', page='last', **kwargs): """ Show all entries with given tag, paginated and filtered. This function accepts the same arguments as `tagged_object_list` and `object_list` generic views. """ # I want to filter out private entries, so I have to use a # queryset based upon request data queryset = queryset.filter(**make_filter_kwargs(request)) if tag is None: return object_list_view(request, queryset, template_object_name=template_object_name, page=page, **kwargs) else: return tagged_object_list(request, queryset, template_object_name=template_object_name, tag=tag, page=page, extra_context={'tag_chunk': "tag/%s/" % tag}, **kwargs)
def tag_detail(request, slug, template_name = 'blog/post_list.html', **kwargs): """ Tag detail Template: ``blog/tag_detail.html`` Context: object_list List of posts specific to the given tag. tag Given tag. """ tag = str(slug).replace('-', ' ') kwargs = { 'template_name':template_name, 'paginate_by':10, 'extra_context':{'content_title':'Posts tagged with <i>"'+tag+'"</i>'} } return tagged_object_list( request, Post.objects.published(), tag, **kwargs )
def blog_archive_tagged(request, **kwargs): kwargs['queryset_or_model'] = kwargs['queryset_or_model'].published() set_language_changer(request, language_changer) return tagged_object_list(request, **kwargs)
def precedents_by_tag(request, tag): queryset = Precedent.published.all() return tagged_object_list(request, queryset, tag, template_name='portfolio/project_list.html',)
def tag_page(request, tag): queryset = Video.objects.all() comments = Comment.objects.order_by("-submit_date")[0:5] categories = Video.CATEGORY_CHOICES return tagged_object_list(request, queryset, tag, paginate_by=5, template_name='index.html', extra_context={'comments': comments, 'categories': categories})
def tagged(request, tag): title = ugettext_lazy("Votes tagged %(tag)s") % {"tag": tag} try: return tagged_object_list(request, queryset_or_model=Vote, tag=tag, extra_context={"title": title}) except Http404: return object_list(request, queryset=Vote.objects.none(), extra_context={"title": title})
def tagged_article_list(request, tag): kwargs = { 'queryset_or_model': Article.objects.published(), 'allow_empty': True, } return tagged_object_list(request, tag=tag, **kwargs)
def approved_recipes(request, tag): queryset = Recipe.approved_objects.all() return tagged_object_list(request, queryset, tag, paginate_by=10, allow_empty=True, template_object_name='recipes')
def tagged_objects(taglist, union): return tagged_object_list(request, queryset, taglist, union=union, *args, **kwargs)