<commit_before>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Authors:
# <NAME> <<EMAIL>>, http://caner.candan.fr
# <NAME> <<EMAIL>>, http://www.vegeclic.fr
#

from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.contrib import messages
from django.core.urlresolvers import reverse, reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from . import models, forms

def set_common_context_data(context):
    context['categories'] = models.Category.objects.all()
    context['tags'] = models.TaggedItem.objects.distinct('tag').order_by('tag').all()
    context['last_articles'] = models.Article.objects.order_by('-date_last_modified').all()
    context['comments'] = models.Comment.objects.order_by('-date_created').all()

class BlogView(generic.ListView):
    model = models.Article
    template_name = 'blog/blog.html'

    def get_queryset(self):
        articles = models.Article.objects.order_by('-period_start', '-date_created').all()

        paginator = Paginator(articles, 10)

        page = self.kwargs.get('page', 1)
        try:
            articles_per_page = paginator.page(page)
        except PageNotAnInteger:
            articles_per_page = paginator.page(1)
        except EmptyPage:
            articles_per_page = paginator.page(paginator.num_pages)

        return articles_per_page

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['section'] = 'blog'
        set_common_context_data(context)
        return context

    def dispatch(self, *args, **kwargs):<commit_msg>* blog/views.py: fixed order issue<commit_after>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Authors:
# <NAME> <<EMAIL>>, http://caner.candan.fr
# <NAME> <<EMAIL>>, http://www.vegeclic.fr
#

from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.contrib import messages
from django.core.urlresolvers import reverse, reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from . import models, forms

def set_common_context_data(context):
    context['categories'] = models.Category.objects.all()
    context['tags'] = models.TaggedItem.objects.distinct('tag').order_by('tag').all()
    context['last_articles'] = models.Article.objects.order_by('-period_start', '-date_created').all()
    context['comments'] = models.Comment.objects.order_by('-date_created').all()

class BlogView(generic.ListView):
    model = models.Article
    template_name = 'blog/blog.html'

    def get_queryset(self):
        articles = models.Article.objects.order_by('-period_start', '-date_created').all()

        paginator = Paginator(articles, 10)

        page = self.kwargs.get('page', 1)
        try:
            articles_per_page = paginator.page(page)
        except PageNotAnInteger:
            articles_per_page = paginator.page(1)
        except EmptyPage:
            articles_per_page = paginator.page(paginator.num_pages)

        return articles_per_page

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['section'] = 'blog'
        set_common_context_data(context)
        return context

    def dispatch(self, *args, **kwargs):
{'fraction_non_alphanumeric': 0.10392506690454952, 'fraction_numerical': 0.00847457627118644, 'mean_word_length': 3.9231613611416027, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6458377', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1248, 'n_words': 388}