<commit_before># -*- coding: utf-8 -*-
# Create your views here.

from django.contrib.auth import logout
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect, render_to_response
from django.template import RequestContext

from core.context_processors import subdomains_context, categories_context
from core.mixins import SubdomainContextMixin, CategoryMixin
from core.models import Region, Subdomain
from core.utils import url_filter
from core.views import RyndaCreateView, RyndaDetailView, RyndaListView

from feed.models import FeedItem

from message.forms import SimpleRequestForm
from message.models import Message


def list(request, slug='all'):
    last_requests = url_filter(Message.objects.filter(messageType=1,status__gt=1,
        status__lt=6).values('id', 'title', 'date_add'), slug)[:5]
    last_offers = Message.objects.filter(messageType=2,status__gt=1,
        status__lt=6).values('id', 'title','date_add')[:5]
    last_completed = Message.objects.filter(messageType=1,status=6)\
        .values('id', 'title','date_add')[:5]
    last_info = Message.objects.filter(messageType=3,status__gt=1,
        status__lt=6).values('id', 'title','date_add')[:5]
    last_feeds = FeedItem.objects.filter(feedId=3).values('id','link',
        'title','date')[:5]
    return render_to_response('index.html',
        { 'regions': Region.objects.all(),
          #'categories': cat_tree,
          'requests': last_requests,
          'offers': last_offers,
          'completed': last_completed,
          'info': last_info,
          'news': last_feeds,
        },
        context_instance=RequestContext(request,
            processors=[subdomains_context, categories_context])
        )


def all(request):
    return render_to_response('all_messages.html',
        {<commit_msg>Last messages query rewritten with new queryset<commit_after># -*- coding: utf-8 -*-
# Create your views here.

from django.contrib.auth import logout
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect, render_to_response
from django.template import RequestContext

from core.context_processors import subdomains_context, categories_context
from core.mixins import SubdomainContextMixin, CategoryMixin
from core.models import Region, Subdomain
from core.utils import url_filter
from core.views import RyndaCreateView, RyndaDetailView, RyndaListView

from feed.models import FeedItem

from message.forms import SimpleRequestForm
from message.models import Message


def list(request, slug='all'):
    last_requests = url_filter(Message.objects.acive().values('id', 'title', 'date_add'), slug)[:5]
    last_offers = Message.objects.filter(messageType=2,status__gt=1,
        status__lt=6).values('id', 'title','date_add')[:5]
    last_completed = Message.objects.filter(messageType=1,status=6)\
        .values('id', 'title','date_add')[:5]
    last_info = Message.objects.filter(messageType=3,status__gt=1,
        status__lt=6).values('id', 'title','date_add')[:5]
    last_feeds = FeedItem.objects.filter(feedId=3).values('id','link',
        'title','date')[:5]
    return render_to_response('index.html',
        { 'regions': Region.objects.all(),
          #'categories': cat_tree,
          'requests': last_requests,
          'offers': last_offers,
          'completed': last_completed,
          'info': last_info,
          'news': last_feeds,
        },
        context_instance=RequestContext(request,
            processors=[subdomains_context, categories_context])
        )


def all(request):
    return render_to_response('all_messages.html',
        {
{'fraction_non_alphanumeric': 0.12048524951750758, 'fraction_numerical': 0.009098428453267164, 'mean_word_length': 4.242774566473988, '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': '2591768', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1065, 'n_words': 221}