<commit_before>from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from rpg_base.models import Location, Campaign


@login_required()
def index(request, pk):
    campaign = get_object_or_404(Campaign, pk=pk)
    locations = get_list_or_404(Location, campaign=pk)
    paginator = Paginator(locations, 25)

    page = request.GET.get('page')

    try:
        locations = paginator.page(page)
    except PageNotAnInteger:
        locations = paginator.page(1)
    except EmptyPage:
        locations = paginator.page(paginator.num_pages)

    context = {
        "locations": locations,
        "campaign": campaign,
    }

    return render_to_response("location/index.html", context)


@login_required
def view(request, pk, location_pk):
    location = get_object_or_404(Location, pk=location_pk, campaign=pk)

    context = {
        "location": location,
    }

    return render_to_response("location/view.html", context)<commit_msg>Location index and view fix<commit_after>from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from rpg_base.models import Location, Campaign


@login_required()
def index(request, campaign_pk):
    campaign = get_object_or_404(Campaign, pk=campaign_pk)
    locations = get_list_or_404(Location, campaign=campaign_pk)
    paginator = Paginator(locations, 25)

    page = request.GET.get('page')

    try:
        locations = paginator.page(page)
    except PageNotAnInteger:
        locations = paginator.page(1)
    except EmptyPage:
        locations = paginator.page(paginator.num_pages)

    context = {
        "locations": locations,
        "campaign": campaign,
    }

    return render_to_response("location/index.html", context)


@login_required
def view(request, campaign_pk, location_pk):
    location = get_object_or_404(Location, pk=location_pk, campaign=campaign_pk)

    context = {
        "location": location,
    }

    return render_to_response("location/view.html", context)
{'fraction_non_alphanumeric': 0.0921577315019938, 'fraction_numerical': 0.01595037660611431, 'mean_word_length': 4.214780600461894, 'pattern_counts': {'":': 6, '<': 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': '3278170', 'n_tokens_mistral': 730, 'n_tokens_neox': 669, 'n_words': 143}