<commit_before>from django.core.urlresolvers import reverse
from django.http import HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.views.generic.list_detail import object_list, object_detail

from builds.models import Build
from builds.filters import BuildFilter
from projects.models import Project

from taggit.models import Tag

def build_list(request, project_slug=None, tag=None):
    """Show a list of builds.
    """
    queryset = Build.objects.all()
    filter = BuildFilter(request.GET, queryset=queryset)

    if tag:
        tag = get_object_or_404(Tag, slug=tag)
        queryset = queryset.filter(project__tags__in=[tag.slug])
    else:
        tag = None

    project = get_object_or_404(Project, slug=project_slug)
    queryset = queryset.filter(project=project)
    active_builds = queryset.exclude(state="finished").values('id')

    return object_list(
        request,
        queryset=queryset,
        extra_context={
            'project': project,
            'filter': filter,
            'tag': tag,
            'active_builds': active_builds
        },
        template_object_name='build',
    )

def build_detail(request, project_slug, pk):
    """Show the details of a particular build.
    """
    project = get_object_or_404(Project, slug=project_slug)
    queryset = Build.objects.filter(project=project)

    return object_detail(
        request,
        queryset=queryset,
        object_id=pk,
        extra_context={'project': project },
        template_object_name='build',
    )
<commit_msg>Move filter to lower in the Build view.<commit_after>from django.core.urlresolvers import reverse
from django.http import HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.views.generic.list_detail import object_list, object_detail

from builds.models import Build
from builds.filters import BuildFilter
from projects.models import Project

from taggit.models import Tag

def build_list(request, project_slug=None, tag=None):
    """Show a list of builds.
    """
    queryset = Build.objects.all()

    if tag:
        tag = get_object_or_404(Tag, slug=tag)
        queryset = queryset.filter(project__tags__in=[tag.slug])
    else:
        tag = None

    project = get_object_or_404(Project, slug=project_slug)
    queryset = queryset.filter(project=project)
    filter = BuildFilter(request.GET, queryset=queryset)
    active_builds = queryset.exclude(state="finished").values('id')

    return object_list(
        request,
        queryset=queryset,
        extra_context={
            'project': project,
            'filter': filter,
            'tag': tag,
            'active_builds': active_builds
        },
        template_object_name='build',
    )

def build_detail(request, project_slug, pk):
    """Show the details of a particular build.
    """
    project = get_object_or_404(Project, slug=project_slug)
    queryset = Build.objects.filter(project=project)

    return object_detail(
        request,
        queryset=queryset,
        object_id=pk,
        extra_context={'project': project },
        template_object_name='build',
    )

{'fraction_non_alphanumeric': 0.09300126103404792, 'fraction_numerical': 0.007566204287515763, 'mean_word_length': 3.247657295850067, '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': '2983788', 'n_tokens_mistral': 944, 'n_tokens_neox': 919, 'n_words': 211}