<commit_before># -*- coding: utf-8 -*-
"""
Akvo RSR is covered by the GNU Affero General Public License.

See more details in the license.txt file located at the root folder of the
Akvo RSR module. For additional details on the GNU license please see
< http://www.gnu.org/licenses/agpl.html >.
"""

import django_filters
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext_lazy as _

from ..filters import (build_choices, ProjectUpdateFilter,
                       remove_empty_querydict_items)
from ..models import ProjectUpdate, Project
from ...utils import pagination, filter_query_string
from .utils import apply_keywords, org_projects, show_filter_class
from .organisation import _page_organisations


###############################################################################
# Projectupdate directory
###############################################################################


def _all_updates():
    """
    Return all project updates.
    """
    return ProjectUpdate.objects.exclude(project__is_public=False).order_by('-id')


def _all_projects():
    """Return all active projects."""
    return Project.objects.public().published().select_related('project_updates')


def _page_updates(page):
    """Dig out the list or project updates to use."""
    projects = org_projects(page.organisation) if page.partner_projects else _all_projects()
    keyword_projects = apply_keywords(page, projects)
    return keyword_projects.all_updates()


def _update_directory_coll(request):
    """Dig out and pass correct projects to the view."""
    page = request.rsr_page<commit_msg>[#2936 #2845] Published & public project updates only in directory<commit_after># -*- coding: utf-8 -*-
"""
Akvo RSR is covered by the GNU Affero General Public License.

See more details in the license.txt file located at the root folder of the
Akvo RSR module. For additional details on the GNU license please see
< http://www.gnu.org/licenses/agpl.html >.
"""

import django_filters
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext_lazy as _

from ..filters import (build_choices, ProjectUpdateFilter,
                       remove_empty_querydict_items)
from ..models import ProjectUpdate, Project
from ...utils import pagination, filter_query_string
from .utils import apply_keywords, org_projects, show_filter_class
from .organisation import _page_organisations


###############################################################################
# Projectupdate directory
###############################################################################


def _public_projects():
    """Return all public projects."""
    return Project.objects.public().published().select_related('project_updates')


def _all_updates():
    """Return all updates on public projects."""
    return _public_projects().all_updates()


def _page_updates(page):
    """Dig out the list or project updates to use."""
    projects = org_projects(page.organisation) if page.partner_projects else _public_projects()
    keyword_projects = apply_keywords(page, projects)
    return keyword_projects.all_updates()


def _update_directory_coll(request):
    """Dig out and pass correct projects to the view."""
    page = request.rsr_page
{'fraction_non_alphanumeric': 0.16824304958440814, 'fraction_numerical': 0.004585841215247922, 'mean_word_length': 5.1335676625659055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '949439', 'n_tokens_mistral': 916, 'n_tokens_neox': 873, 'n_words': 289}