<commit_before>import logging
l = logging.getLogger(__name__)

from datetime import date, timedelta

from django.contrib.admin.views.decorators import staff_member_required
from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404
from django.template import Context, RequestContext
from django.views.decorators.cache import never_cache

from experiments.models import (Experiment, Participant, GoalRecord,
                                DailyEngagementReport)
from experiments.reports import get_conversion_data
from experiments.util import WebUser

experiment_states= {"enabled": Experiment.ENABLED_STATE,
  "disabled": Experiment.DISABLED_STATE,
  "promoted": Experiment.PROMOTED_STATE}

TRANSPARENT_1X1_PNG = \
("\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
 "\x00\x00\x00\x01\x00\x00\x00\x01\x08\x03\x00\x00\x00\x28\xcb\x34"
 "\xbb\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72"
 "\x65\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61"
 "\x64\x79\x71\xc9\x65\x3c\x00\x00\x00\x06\x50\x4c\x54\x45\x00\x00"
 "\x00\x00\x00\x00\xa5\x67\xb9\xcf\x00\x00\x00\x01\x74\x52\x4e\x53"
 "\x00\x40\xe6\xd8\x66\x00\x00\x00\x0c\x49\x44\x41\x54\x78\xda\x62"
 "\x60\x00\x08\x30\x00\x00\x02\x00\x01\x4f\x6d\x59\xe1\x00\x00\x00"
 "\x00\x49\x45\x4e\x44\xae\x42\x60\x82\x00")


@never_cache
def confirm_human(request):
    experiment_user = WebUser(request)
    experiment_user.confirm_human()
    return HttpResponse(status=204)


@never_cache
def record_experiment_goal(request, goal_name):
    try:
        GoalRecord.record(goal_name, WebUser(request))
    except Exception, e:
        l.warn("unknown goal type '%s': %s" % (goal_name, e))

    return HttpResponse(TRANSPARENT_1X1_PNG, mimetype="image/png")


@staff_member_required
def list_experiments(request, template_name='experiments/list_experiments.html'):
    """docstring for list_experiments"""
    context_var = {"experiments": Experiment.objects.order_by("-start_date"),
                   "experiment_states": experiment_states,
                   "root_path": "../",
                   "title": "Experiments"}

    return render_to_response(template_name, context_var,
                              context_instance=RequestContext(request))


@staff_member_required
def experiment_details(request, experiment_name,<commit_msg>Remove the staff_member_required decorator to make the app more easily re-usable in other projects. This way a permission checking decorator can be applied in the urls.py file.<commit_after>import logging
l = logging.getLogger(__name__)

from datetime import date, timedelta

from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404
from django.template import Context, RequestContext
from django.views.decorators.cache import never_cache

from experiments.models import (Experiment, Participant, GoalRecord,
                                DailyEngagementReport)
from experiments.reports import get_conversion_data
from experiments.util import WebUser

experiment_states= {"enabled": Experiment.ENABLED_STATE,
  "disabled": Experiment.DISABLED_STATE,
  "promoted": Experiment.PROMOTED_STATE}

TRANSPARENT_1X1_PNG = \
("\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
 "\x00\x00\x00\x01\x00\x00\x00\x01\x08\x03\x00\x00\x00\x28\xcb\x34"
 "\xbb\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72"
 "\x65\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61"
 "\x64\x79\x71\xc9\x65\x3c\x00\x00\x00\x06\x50\x4c\x54\x45\x00\x00"
 "\x00\x00\x00\x00\xa5\x67\xb9\xcf\x00\x00\x00\x01\x74\x52\x4e\x53"
 "\x00\x40\xe6\xd8\x66\x00\x00\x00\x0c\x49\x44\x41\x54\x78\xda\x62"
 "\x60\x00\x08\x30\x00\x00\x02\x00\x01\x4f\x6d\x59\xe1\x00\x00\x00"
 "\x00\x49\x45\x4e\x44\xae\x42\x60\x82\x00")


@never_cache
def confirm_human(request):
    experiment_user = WebUser(request)
    experiment_user.confirm_human()
    return HttpResponse(status=204)


@never_cache
def record_experiment_goal(request, goal_name):
    try:
        GoalRecord.record(goal_name, WebUser(request))
    except Exception, e:
        l.warn("unknown goal type '%s': %s" % (goal_name, e))

    return HttpResponse(TRANSPARENT_1X1_PNG, mimetype="image/png")


def list_experiments(request, template_name='experiments/list_experiments.html'):
    """docstring for list_experiments"""
    context_var = {"experiments": Experiment.objects.order_by("-start_date"),
                   "experiment_states": experiment_states,
                   "root_path": "../",
                   "title": "Experiments"}

    return render_to_response(template_name, context_var,
                              context_instance=RequestContext(request))


def experiment_details(request, experiment_name,
{'fraction_non_alphanumeric': 0.12998955067920584, 'fraction_numerical': 0.10616509926854754, 'mean_word_length': 3.8197381671701915, 'pattern_counts': {'":': 14, '<': 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': '470290', 'n_tokens_mistral': 2154, 'n_tokens_neox': 1888, 'n_words': 247}