<commit_before>from functools import update_wrapper

from django.shortcuts import render_to_response, redirect
from django.template import RequestContext

from django.contrib import admin
from django.contrib.admin import helpers

from .forms import OneOffPointAwardForm
from .models import PointValue, AwardedPointValue


class AwardedPointValueAdmin(admin.ModelAdmin):
    list_display = ["pk", "reason_display", "target", "points"]
    fields = ["target_user", "value", "timestamp"]

    def target(self, obj):
        if obj.target_user_id:
            return obj.target_user
        else:
            return obj.target_object

    def reason_display(self, obj):
        if obj.value_id:
            return obj.value.key
        else:
            if obj.reason:
                return obj.reason
            else:
                return None
    reason_display.short_description = "reason"

    def get_urls(self):
        from django.conf.urls import patterns, url

        urlpatterns = super(AwardedPointValueAdmin, self).get_urls()

        def wrap(view):
            def wrapper(*args, **kwargs):
                return self.admin_site.admin_view(view)(*args, **kwargs)
            return update_wrapper(wrapper, view)

        return patterns(
            "",
            url(
                r"^one_off_points/$",
                wrap(self.one_off_points),
                name="{0}_{1}_one_off_points".format(self.model._meta.app_label, self.model._meta.module_name)
            )
        ) + urlpatterns

    def one_off_points(self, request):
        if request.method == "POST":
            form = OneOffPointAwardForm(request.POST)
            if form.is_valid():<commit_msg>Handle model meta api change<commit_after>import django

from functools import update_wrapper

from django.shortcuts import render_to_response, redirect
from django.template import RequestContext

from django.contrib import admin
from django.contrib.admin import helpers

from .forms import OneOffPointAwardForm
from .models import PointValue, AwardedPointValue


class AwardedPointValueAdmin(admin.ModelAdmin):
    list_display = ["pk", "reason_display", "target", "points"]
    fields = ["target_user", "value", "timestamp"]

    def target(self, obj):
        if obj.target_user_id:
            return obj.target_user
        else:
            return obj.target_object

    def reason_display(self, obj):
        if obj.value_id:
            return obj.value.key
        else:
            if obj.reason:
                return obj.reason
            else:
                return None
    reason_display.short_description = "reason"

    def get_urls(self):
        from django.conf.urls import patterns, url

        urlpatterns = super(AwardedPointValueAdmin, self).get_urls()

        def wrap(view):
            def wrapper(*args, **kwargs):
                return self.admin_site.admin_view(view)(*args, **kwargs)
            return update_wrapper(wrapper, view)

        if django.VERSION < (1, 7):
            info = self.model._meta.app_label, self.model._meta.module_name
        else:
            info = self.model._meta.app_label, self.model._meta.model_name
        return patterns(
            "",
            url(
                r"^one_off_points/$",
                wrap(self.one_off_points),
                name="{0}_{1}_one_off_points".format(info[0], info[1])
            )
        ) + urlpatterns

    def one_off_points(self, request):
        if request.method == "POST":
            form = OneOffPointAwardForm(request.POST)
            if form.is_valid():
{'fraction_non_alphanumeric': 0.09319899244332494, 'fraction_numerical': 0.002239014833473272, 'mean_word_length': 2.2819100091827367, 'pattern_counts': {'":': 2, '<': 4, '<?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': '2603401', 'n_tokens_mistral': 1004, 'n_tokens_neox': 978, 'n_words': 230}