Ejemplo n.º 1
0
"""Views for blog 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.blog.models import Entry
from lincdm.blog.views.decorators import protect_entry
from lincdm.blog.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)
Ejemplo n.º 2
0
"""Views for blog 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.blog.settings import PAGINATION
from lincdm.blog.views.decorators import update_queryset
from lincdm.blog.views.decorators import template_name_for_entry_queryset_filtered


author_list = update_queryset(object_list, Author.published.all)


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.blog_entries_published(),
                       paginate_by=PAGINATION, page=page,
                       **kwargs)
Ejemplo n.º 3
0
"""Views for blog 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.blog.models import Entry
from lincdm.blog.views.decorators import protect_entry
from lincdm.blog.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)
Ejemplo n.º 4
0
"""Views for blog 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.blog.settings import PAGINATION
from lincdm.blog.views.decorators import update_queryset
from lincdm.blog.views.decorators import template_name_for_entry_queryset_filtered

author_list = update_queryset(object_list, Author.published.all)


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.blog_entries_published(),
                       paginate_by=PAGINATION,
                       page=page,
                       **kwargs)
Ejemplo n.º 5
0
"""Views for blog tags"""
from django.views.generic.list_detail import object_list

from tagging.views import tagged_object_list

from lincdm.blog.models import Entry
from lincdm.blog.settings import PAGINATION
from lincdm.blog.managers import tags_published
from lincdm.blog.views.decorators import update_queryset
from lincdm.blog.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)
Ejemplo n.º 6
0
"""Views for blog tags"""
from django.views.generic.list_detail import object_list

from tagging.views import tagged_object_list

from lincdm.blog.models import Entry
from lincdm.blog.settings import PAGINATION
from lincdm.blog.managers import tags_published
from lincdm.blog.views.decorators import update_queryset
from lincdm.blog.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)