<commit_before>from django.http import HttpResponse, HttpResponseRedirect
from django.template import Context, RequestContext, loader
from django.http import Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.conf import settings 
from django.db.models import Q
from django.contrib.auth.decorators import login_required

import os

from signbank.dictionary.models import *
from signbank.dictionary.forms import * 
from signbank.feedback.models import *

def login_required_config(f):
    """like @login_required if the ALWAYS_REQUIRE_LOGIN setting is True"""

    if settings.ALWAYS_REQUIRE_LOGIN:
        return login_required(f)
    else:
        return f



@login_required_config
def index(request, flavour='dictionary'):
    """Default view showing a browse/search entry
    point to the dictionary"""
    
    
    return render_to_response("dictionary/index.html",
                              {'flavour': flavour,
                               },
                               context_instance=RequestContext(request))

STATE_IMAGES = {'auslan_all': "images/maps/allstates.gif",
                'auslan_nsw_act_qld': "images/maps/nsw-act-qld.gif",
                'auslan_nsw': "images/maps/nsw.gif",
                'auslan_nt':  "images/maps/nt.gif",
                'auslan_qld': "images/maps/qld.gif",
                'auslan_sa': "images/maps/sa.gif",
                'auslan_tas': "images/maps/tas.gif",
                'auslan_south': "images/maps/vic-wa-tas-sa-nt.gif",
                'auslan_vic': "images/maps/vic.gif",
                'auslan_wa': "images/maps/wa.gif",
                }

def map_image_for_dialects(dialects):
    """Get the right map image for this dialect set
    
    
    Relies on database contents, which is bad. This should
    be in the database
    """
    # we only work for Auslan just now
    dialects = dialects.filter(language__name__exact="Auslan")

    if len(dialects) == 0:
        return 
    
    # all states 
    if len(dialects) == 8:
        return STATE_IMAGES['auslan_all']
    
    if dialects.filter(name__exact="Southern Dialect"):
        return STATE_IMAGES['auslan_south']
    
    if dialects.filter(name__exact="Northern Dialect"):
        return STATE_IMAGES['auslan_nsw_act_qld']
    
    if dialects.filter(name__exact="New South Wales"):<commit_msg>Fix map generation to match new dialect model<commit_after>from django.http import HttpResponse, HttpResponseRedirect
from django.template import Context, RequestContext, loader
from django.http import Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.conf import settings 
from django.db.models import Q
from django.contrib.auth.decorators import login_required

import os

from signbank.dictionary.models import *
from signbank.dictionary.forms import * 
from signbank.feedback.models import *

def login_required_config(f):
    """like @login_required if the ALWAYS_REQUIRE_LOGIN setting is True"""

    if settings.ALWAYS_REQUIRE_LOGIN:
        return login_required(f)
    else:
        return f



@login_required_config
def index(request, flavour='dictionary'):
    """Default view showing a browse/search entry
    point to the dictionary"""
    
    
    return render_to_response("dictionary/index.html",
                              {'flavour': flavour,
                               },
                               context_instance=RequestContext(request))

STATE_IMAGES = {'auslan_all': "images/maps/allstates.gif",
                'auslan_nsw_act_qld': "images/maps/nsw-act-qld.gif",
                'auslan_nsw': "images/maps/nsw.gif",
                'auslan_nt':  "images/maps/nt.gif",
                'auslan_qld': "images/maps/qld.gif",
                'auslan_sa': "images/maps/sa.gif",
                'auslan_tas': "images/maps/tas.gif",
                'auslan_south': "images/maps/vic-wa-tas-sa-nt.gif",
                'auslan_vic': "images/maps/vic.gif",
                'auslan_wa': "images/maps/wa.gif",
                }

def map_image_for_dialects(dialects):
    """Get the right map image for this dialect set
    
    
    Relies on database contents, which is bad. This should
    be in the database
    """
    # we only work for Auslan just now
    dialects = dialects.filter(language__name__exact="Auslan")

    if len(dialects) == 0:
        return 
    
    # all states 
    if dialects.filter(name__exact="Australia Wide"):
        return STATE_IMAGES['auslan_all']
    
    if dialects.filter(name__exact="Southern Dialect"):
        return STATE_IMAGES['auslan_south']
    
    if dialects.filter(name__exact="Northern Dialect"):
        return STATE_IMAGES['auslan_nsw_act_qld']
    
    if dialects.filter(name__exact="New South Wales"):
{'fraction_non_alphanumeric': 0.09764102564102564, 'fraction_numerical': 0.003076923076923077, 'mean_word_length': 2.6551724137931036, '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': '4076471', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1445, 'n_words': 330}