<commit_before>""" Views for the base application """

import datetime
import os.path
import re
from django.shortcuts import render
from django.http import Http404
from django.conf import settings
from django.utils.translation import ungettext
from django.contrib.sites.models import Site
from django_transfer import TransferHttpResponse

from grappelli.views.related import (AutocompleteLookup, get_label,
                                     ajax_response, never_cache, )
from grappelli.settings import AUTOCOMPLETE_LIMIT

from accounts.models import UserSite
from genealogio.models import Person
from notaro.models import Note, Picture, Document
from comments.models import Comment


class CurrentSiteMixin(object):
    def get_queryset(self):
        qs = super(CurrentSiteMixin, self).get_queryset()
        return qs.filter(sites=self.request.site)


def home(request):
    """ Default view for the root """

    # pylint: disable=no-member
    dates = [datetime.date.today() + (i-4) * datetime.timedelta(days=1)
             for i in range(20)]
    birthdeathdays = [
            (d,
             Person.objects
             .filter(datebirth__endswith=d.strftime('-%m-%d')),
             Person.objects
             .filter(datedeath__endswith=d.strftime('-%m-%d')), )
            for d in dates]
    birthdeathdays = [(d, born, died)
                      for d, born, died in birthdeathdays if born or died]

    # pylint: disable=no-member
    return render(
            request, 'base/home.html',
            {'personen': Person.objects.all().order_by('-date_added')[:5],
             'comments': Comment.objects.all().order_by('-date')[:5],
             'birthdeathdays': birthdeathdays,
             'today': datetime.date.today(),
             'notes': Note.objects.filter(published=True)
                          .order_by('date_added')[:5], })

protected_path = re.compile('\d+_')


def download(request, fname):<commit_msg>Fix ordering in display of latest notes on home page.<commit_after>""" Views for the base application """

import datetime
import os.path
import re
from django.shortcuts import render
from django.http import Http404
from django.conf import settings
from django.utils.translation import ungettext
from django.contrib.sites.models import Site
from django_transfer import TransferHttpResponse

from grappelli.views.related import (AutocompleteLookup, get_label,
                                     ajax_response, never_cache, )
from grappelli.settings import AUTOCOMPLETE_LIMIT

from accounts.models import UserSite
from genealogio.models import Person
from notaro.models import Note, Picture, Document
from comments.models import Comment


class CurrentSiteMixin(object):
    def get_queryset(self):
        qs = super(CurrentSiteMixin, self).get_queryset()
        return qs.filter(sites=self.request.site)


def home(request):
    """ Default view for the root """

    # pylint: disable=no-member
    dates = [datetime.date.today() + (i-4) * datetime.timedelta(days=1)
             for i in range(20)]
    birthdeathdays = [
            (d,
             Person.objects
             .filter(datebirth__endswith=d.strftime('-%m-%d')),
             Person.objects
             .filter(datedeath__endswith=d.strftime('-%m-%d')), )
            for d in dates]
    birthdeathdays = [(d, born, died)
                      for d, born, died in birthdeathdays if born or died]

    # pylint: disable=no-member
    return render(
            request, 'base/home.html',
            {'personen': Person.objects.all().order_by('-date_added')[:5],
             'comments': Comment.objects.all().order_by('-date')[:5],
             'birthdeathdays': birthdeathdays,
             'today': datetime.date.today(),
             'notes': Note.objects.filter(published=True)
                          .order_by('-date_added')[:5], })

protected_path = re.compile('\d+_')


def download(request, fname):
{'fraction_non_alphanumeric': 0.1110828025477707, 'fraction_numerical': 0.005095541401273885, 'mean_word_length': 2.767754318618042, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1720014', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1084, 'n_words': 282}