<commit_before>import os
from django.conf import settings
from django.shortcuts import get_object_or_404, render_to_response, render
from django.template.loader import render_to_string
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseBadRequest, Http404
from django.utils.decorators import method_decorator
from django.views.decorators.clickjacking import xframe_options_exempt, xframe_options_sameorigin
from django.core.urlresolvers import reverse
from django.core import serializers
from django.template import RequestContext, Context, loader
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.views.generic import View, ListView, DetailView
from django.db.models import Q, Avg, Max, Min, Sum, Count
from measure_finance.models import Measure, MeasureContributor, MeasureTotal
from bakery.views import BuildableListView, BuildableDetailView
import logging

logger = logging.getLogger("kpcc_backroom_handshakes")

class InitialListView(BuildableListView):
    """ """
    model = Measure
    template_name = "measure_finance/index.html"

@method_decorator(xframe_options_exempt, name='get_object')
class InitialDetailView(BuildableDetailView):
    """ """
    model = Measure
    template_name = "measure_finance/detail.html"
    slug_field = "official_identifier_slug"
    sub_directory = "measure-finance/"

    def get_object(self):
        object = super(InitialDetailView, self).get_object()
        return object

    def get_url(self, obj):
        """
        the url at which the detail page should appear.
        """
        return "/%s" % (obj.official_identifier_slug)

    def get_build_path(self, obj):
        """
        used to determine where to build the detail page. override this if you
        would like your detail page at a different location. by default it
        will be built at get_url() + "index.html"
        """
        path = os.path.join(settings.BUILD_DIR, self.sub_directory, self.get_url(obj)[1:])
        os.path.exists(path) or os.makedirs(path)
        return os.path.join(path, "index.html")

    def get_context_data(self, **kwargs):
        context = super(InitialDetailView, self).get_context_data(**kwargs)
        aggregate_contribs = MeasureTotal.objects.filter(measure_id=self.object.id)
        context["total_support"] = aggregate_contribs.filter(support="Yes").first()
        if context["total_support"]:
            context["support_unitemized"] = context["total_support"].total_unitemized
        else:
            context["support_unitemized"] = None
        if context["total_support"]:
            context["support_itemized"] = context["total_support"].total_itemized
        else:
            context["support_itemized"] = None
        if context["total_support"] == None:<commit_msg>pushes x-frame exempt view live and to repo'<commit_after>import os
from django.conf import settings
from django.shortcuts import get_object_or_404, render_to_response, render
from django.template.loader import render_to_string
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseBadRequest, Http404
from django.utils.decorators import method_decorator
from django.views.decorators.clickjacking import xframe_options_exempt, xframe_options_sameorigin
from django.core.urlresolvers import reverse
from django.core import serializers
from django.template import RequestContext, Context, loader
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.views.generic import View, ListView, DetailView
from django.db.models import Q, Avg, Max, Min, Sum, Count
from measure_finance.models import Measure, MeasureContributor, MeasureTotal
from bakery.views import BuildableListView, BuildableDetailView
import logging

logger = logging.getLogger("kpcc_backroom_handshakes")

class InitialListView(BuildableListView):
    """ """
    model = Measure
    template_name = "measure_finance/index.html"

@method_decorator(xframe_options_exempt, name='dispatch')
class InitialDetailView(BuildableDetailView):
    """ """
    model = Measure
    template_name = "measure_finance/detail.html"
    slug_field = "official_identifier_slug"
    sub_directory = "measure-finance/"

    def get_object(self):
        object = super(InitialDetailView, self).get_object()
        return object

    def get_url(self, obj):
        """
        the url at which the detail page should appear.
        """
        return "/%s" % (obj.official_identifier_slug)

    def get_build_path(self, obj):
        """
        used to determine where to build the detail page. override this if you
        would like your detail page at a different location. by default it
        will be built at get_url() + "index.html"
        """
        path = os.path.join(settings.BUILD_DIR, self.sub_directory, self.get_url(obj)[1:])
        os.path.exists(path) or os.makedirs(path)
        return os.path.join(path, "index.html")

    def dispatch(self, *args, **kwargs):
        return super(InitialDetailView, self).dispatch(*args, **kwargs)

    def get_context_data(self, **kwargs):
        context = super(InitialDetailView, self).get_context_data(**kwargs)
        aggregate_contribs = MeasureTotal.objects.filter(measure_id=self.object.id)
        context["total_support"] = aggregate_contribs.filter(support="Yes").first()
        if context["total_support"]:
            context["support_unitemized"] = context["total_support"].total_unitemized
        else:
            context["support_unitemized"] = None
        if context["total_support"]:
            context["support_itemized"] = context["total_support"].total_itemized
        else:
            context["support_itemized"] = None
        if context["total_support"] == None:
{'fraction_non_alphanumeric': 0.09262792714657415, 'fraction_numerical': 0.0024284475281873374, 'mean_word_length': 4.044619422572178, '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': '1040288', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1576, 'n_words': 404}