"""Views for entry entries""" from django.shortcuts import redirect from django.shortcuts import get_object_or_404 from django.views.generic.list_detail import object_list from django.views.generic.date_based import archive_year from django.views.generic.date_based import archive_month from django.views.generic.date_based import archive_day from django.views.generic.date_based import object_detail from lincdm.entry.models import Entry from lincdm.views.decorators import protect_entry from lincdm.views.decorators import update_queryset entry_index = update_queryset(object_list, Entry.published.all) entry_year = update_queryset(archive_year, Entry.published.all) entry_month = update_queryset(archive_month, Entry.published.all) entry_day = update_queryset(archive_day, Entry.published.all) entry_detail = protect_entry(object_detail) def entry_shortlink(request, object_id): """ Redirect to the 'get_absolute_url' of an Entry, accordingly to 'object_id' argument """ entry = get_object_or_404(Entry, pk=object_id)
"""Views for entry entries""" from django.shortcuts import redirect from django.shortcuts import get_object_or_404 from django.views.generic.list_detail import object_list from django.views.generic.date_based import archive_year from django.views.generic.date_based import archive_month from django.views.generic.date_based import archive_day from django.views.generic.date_based import object_detail from lincdm.entry.models import Entry from lincdm.views.decorators import protect_entry from lincdm.views.decorators import update_queryset entry_index = update_queryset(object_list, Entry.published.all) entry_year = update_queryset(archive_year, Entry.published.all) entry_month = update_queryset(archive_month, Entry.published.all) entry_day = update_queryset(archive_day, Entry.published.all) entry_detail = protect_entry(object_detail) def entry_shortlink(request, object_id): """ Redirect to the 'get_absolute_url' of an Entry, accordingly to 'object_id' argument """ entry = get_object_or_404(Entry, pk=object_id) return redirect(entry, permanent=True)
"""Views for entry authors""" from django.shortcuts import get_object_or_404 from django.views.generic.list_detail import object_list from lincdm.models.models import Author from lincdm.settings import PAGINATION from lincdm.views.decorators import update_queryset from lincdm.views.decorators import template_name_for_entry_queryset_filtered from django.views.decorators.cache import cache_page author_list = update_queryset(object_list, Author.published.all) @cache_page(60 * 300) def author_detail(request, username, page=None, **kwargs): """Display the entries of an author""" extra_context = kwargs.pop('extra_context', {}) author = get_object_or_404(Author, username=username) if not kwargs.get('template_name'): kwargs['template_name'] = template_name_for_entry_queryset_filtered( 'author', author.username) extra_context.update({'author': author}) kwargs['extra_context'] = extra_context return object_list(request, queryset=author.entries_published(), paginate_by=PAGINATION, page=page, **kwargs)
"""Views for entry tags""" from django.views.generic.list_detail import object_list from tagging.views import tagged_object_list from lincdm.entry.models import Entry from lincdm.settings import PAGINATION from lincdm.managers import tags_published from lincdm.views.decorators import update_queryset from lincdm.views.decorators import template_name_for_entry_queryset_filtered tag_list = update_queryset(object_list, tags_published) 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', tag) return tagged_object_list(request, tag=tag, queryset_or_model=Entry.published.all(), paginate_by=PAGINATION, page=page, **kwargs)