Revision bd9ce789 cloudcmsblog/views.py

b/cloudcmsblog/views.py
35 35
from django.conf import settings
36 36
from django.views.generic.simple import direct_to_template
37 37
from django.http import HttpResponseRedirect, Http404
38
from django.shortcuts import get_object_or_404
38 39

  
39 40
from cloudcms.models import Application
40 41
from cloudcmsblog.models import Entry, Category, CategoryTranslation
......
49 50

  
50 51
    return HttpResponseRedirect(categories[0].get_absolute_url())
51 52

  
53

  
52 54
def archive(request, category):
53 55
    """
54 56
    Display entries list
55 57
    """
56 58
    app = Application.current()
57
    category = CategoryTranslation.objects.get(slug=category).parent
59
    category = get_object_or_404(Category, translations__slug=category)
58 60
    entries = category.blogentries.all()
59 61
    return direct_to_template(request,
60 62
            "cloudcmsblog/archive.html", {'entries': entries,
61 63
                'ENTRIES_PER_PAGE': getattr(settings,
62 64
                    'CLOUDCMSBLOG_ENTRIES_PER_PAGE', 2)})
63 65

  
66

  
64 67
def detail(request, year, month, day, slug):
65 68
    """
66 69
    Display detailed blog entry.
67 70
    """
68
    entry = Entry.objects.get(published_on__year=year,
71
    entry = get_object_or_404(Entry, published_on__year=year,
69 72
            published_on__month=month, published_on__day=day,
70 73
            slug=slug, is_active=True)
71 74
    return direct_to_template(request,

Also available in: Unified diff