<commit_before>from django.utils import timezone
from django.core.urlresolvers import reverse

from django.views.generic.list import ListView
from django.views.generic.detail import DetailView

from .models import PressRelease, PressMention


class PressReleaseListView(ListView):
    model = PressRelease

    def get_queryset(self):
        return PressRelease.objects.filter(release_date__lt=timezone.now())

    def get_context_data(self, **kwargs):
        context = super(PressReleaseListView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'objects': PressMention.objects.all()[:5],
            'fulllist': reverse('press-mentions')
            }
        return context


class PressReleaseDetailView(DetailView):
    model = PressRelease

    def get_context_data(self, **kwargs):
        context = super(PressReleaseDetailView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'releases': PressRelease.objects\
                .exclude(pk=context['object'].pk)\
                .filter(release_date__lt=timezone.now())[:5],
            'mentions': PressMention.objects.all()[:5]
            }
        return context


class PressMentionListView(ListView):

    model = PressMention

    def get_context_data(self, **kwargs):
        context = super(PressMentionListView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'objects': PressRelease.objects.all()[:5],
            'fulllist': reverse('press-releases')
            }<commit_msg>press: future releases should not be accessible via slug<commit_after>from django.utils import timezone
from django.core.urlresolvers import reverse

from django.views.generic.list import ListView
from django.views.generic.detail import DetailView

from .models import PressRelease, PressMention


class PressReleaseListView(ListView):
    model = PressRelease

    def get_queryset(self):
        return PressRelease.objects.filter(release_date__lt=timezone.now())

    def get_context_data(self, **kwargs):
        context = super(PressReleaseListView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'objects': PressMention.objects.all()[:5],
            'fulllist': reverse('press-mentions')
            }
        return context


class PressReleaseDetailView(DetailView):
    model = PressRelease

    def get_queryset(self):
        return PressRelease.objects.filter(release_date__lt=timezone.now())

    def get_context_data(self, **kwargs):
        context = super(PressReleaseDetailView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'releases': PressRelease.objects\
                .exclude(pk=context['object'].pk)\
                .filter(release_date__lt=timezone.now())[:5],
            'mentions': PressMention.objects.all()[:5]
            }
        return context


class PressMentionListView(ListView):

    model = PressMention

    def get_context_data(self, **kwargs):
        context = super(PressMentionListView, self).get_context_data(**kwargs)
        context['sidebar_recent'] = {
            'objects': PressRelease.objects.all()[:5],
            'fulllist': reverse('press-releases')
            }
{'fraction_non_alphanumeric': 0.11261538461538462, 'fraction_numerical': 0.0024615384615384616, 'mean_word_length': 3.184041184041184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4300396', 'n_tokens_mistral': 923, 'n_tokens_neox': 867, 'n_words': 164}