<commit_before>from django.shortcuts import render_to_response
from django.conf import settings
from django.core.context_processors import csrf
from oabutton.common import SigninForm, teamdata, thanksdata
import json


def homepage(req):
    # Need to lazy import the Event model so that tests work with
    # mocks
    c = {}
    c.update(csrf(req))

    from oabutton.apps.bookmarklet.models import Event

    evt_count = Event.objects.count()
    data = []

    for evt in Event.objects.all():
        data.append({'doi': evt.doi,
                     'coords': dict(evt.coords),
                     'accessed': evt.accessed.strftime("%b %d, %Y"),
                     'user_name': evt.user_name,
                     'user_profession': evt.user_profession,
                     'description': evt.description,
                     'story': evt.story,
                     'url': evt.url,
                     })

    c.update({'DEBUG': settings.DEBUG,
              'count': evt_count,
              'events': json.dumps(data),
              'hostname': settings.HOSTNAME,
              'signin_form': SigninForm(),
              'team_data': teamdata,
              'thanks_data': thanksdata})

    return render_to_response('web/start.jade', c)<commit_msg>Inject request context into web template<commit_after>from django.shortcuts import render_to_response
from django.template import RequestContext
from django.conf import settings
from django.core.context_processors import csrf
from oabutton.common import SigninForm, teamdata, thanksdata
import json


def homepage(req):
    # Need to lazy import the Event model so that tests work with
    # mocks
    c = {}
    c.update(csrf(req))

    from oabutton.apps.bookmarklet.models import Event

    evt_count = Event.objects.count()
    data = []

    for evt in Event.objects.all():
        data.append({'doi': evt.doi,
                     'coords': dict(evt.coords),
                     'accessed': evt.accessed.strftime("%b %d, %Y"),
                     'user_name': evt.user_name,
                     'user_profession': evt.user_profession,
                     'description': evt.description,
                     'story': evt.story,
                     'url': evt.url,
                     })

    c.update({'DEBUG': settings.DEBUG,
              'count': evt_count,
              'events': json.dumps(data),
              'hostname': settings.HOSTNAME,
              'signin_form': SigninForm(),
              'team_data': teamdata,
              'thanks_data': thanksdata})

    return render_to_response('web/start.jade', c,
                              context_instance=RequestContext(req))
{'fraction_non_alphanumeric': 0.10773273273273273, 'fraction_numerical': 0.0, 'mean_word_length': 1.9809843400447427, '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': '7218087', 'n_tokens_mistral': 756, 'n_tokens_neox': 749, 'n_words': 175}