<commit_before>from datetime import datetime
from django.http import Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.views.generic import (
    ArchiveIndexView,
    YearArchiveView,
    MonthArchiveView,
)
from tinyblog.models import Post


def post(request, year, month, slug):
    post = get_object_or_404(Post, created__year=year, created__month=month,
                             slug=slug)

    if post.created > datetime.now():
        if not request.user.is_staff:
            raise Http404

    return render_to_response('tinyblog/post.html',
                              {'post': post},
                              context_instance=RequestContext(request))


class TinyBlogIndexView(ArchiveIndexView):
    date_field = 'created'

    def get_queryset(self):
        return Post.published_objects.all()
index_view = TinyBlogIndexView.as_view()


class TinyBlogYearView(YearArchiveView):
    date_field = 'created'
    make_object_list = True

    def get_queryset(self):
        return Post.published_objects.all()
year_view = TinyBlogYearView.as_view()


class TinyBlogMonthView(MonthArchiveView):
    date_field = 'created'
    month_format = '%m'
<commit_msg>Switch the main post detail view to a CBV<commit_after>from datetime import datetime
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.views.generic import (
    ArchiveIndexView,
    YearArchiveView,
    MonthArchiveView,
    DetailView,
)
from tinyblog.models import Post


class TinyBlogPostView(DetailView):
    template_name = 'tinyblog/post.html'

    def get_object(self):
        post = get_object_or_404(
            Post,
            created__year=int(self.kwargs['year']),
            created__month=int(self.kwargs['month']),
            slug=self.kwargs['slug']
        )

        if post.created > datetime.now():
            if not self.request.user.is_staff:
                raise Http404
        return post
post = TinyBlogPostView.as_view()


class TinyBlogIndexView(ArchiveIndexView):
    date_field = 'created'

    def get_queryset(self):
        return Post.published_objects.all()
index_view = TinyBlogIndexView.as_view()


class TinyBlogYearView(YearArchiveView):
    date_field = 'created'
    make_object_list = True

    def get_queryset(self):
        return Post.published_objects.all()
year_view = TinyBlogYearView.as_view()


class TinyBlogMonthView(MonthArchiveView):
    date_field = 'created'
    month_format = '%m'

{'fraction_non_alphanumeric': 0.08316987053746568, 'fraction_numerical': 0.009415457041977247, 'mean_word_length': 3.2218543046357615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6785071', 'n_tokens_mistral': 799, 'n_tokens_neox': 727, 'n_words': 161}