<commit_before>from __future__ import unicode_literals

from django.contrib import admin

from django.core.urlresolvers import reverse
from django.forms import ModelForm

from .models import LoggedAction, PartySet, ExtraField, PersonExtraFieldValue, SimplePopoloField
# Register your models here.


class LoggedActionAdminForm(ModelForm):
    pass


@admin.register(LoggedAction)
class LoggedActionAdmin(admin.ModelAdmin):
    form = LoggedActionAdminForm
    search_fields = ('user__username', 'popit_person_new_version',
                     'person', 'ip_address', 'source')
    list_filter = ('action_type',)
    list_display = ['user', 'ip_address', 'action_type',
                    'popit_person_new_version', 'person_link',
                    'created', 'updated', 'source']
    ordering = ('-created',)

    def person_link(self, o):
        if not o.person:
            return ''
        url = reverse('person-view', kwargs={'person_id': o.person.id})
        return '<a href="{0}">{1}</a>'.format(
            url,
            o.person.name,
        )
    person_link.allow_tags = True


class PartySetAdminForm(ModelForm):
    pass


@admin.register(PartySet)
class PartySetAdmin(admin.ModelAdmin):
    form = PartySetAdminForm


class ExtraFieldAdminForm(ModelForm):
    pass


@admin.register(ExtraField)
class ExtraFieldAdmin(admin.ModelAdmin):
    form = ExtraFieldAdminForm


class PersonExtraFieldValueAdminForm(ModelForm):
    pass


@admin.register(PersonExtraFieldValue)
class PersonExtraFieldValueAdmin(admin.ModelAdmin):
    form = PersonExtraFieldValueAdminForm


@admin.register(SimplePopoloField)
class SimplePopoloFieldAdmin(admin.ModelAdmin):
    list_display = ['name', 'label']<commit_msg>Admin for per post winner count<commit_after>from __future__ import unicode_literals

from django.contrib import admin

from django.core.urlresolvers import reverse
from django.forms import ModelForm

from .models import (
    LoggedAction, PartySet, ExtraField, PersonExtraFieldValue,
    SimplePopoloField, PostExtraElection
)


class LoggedActionAdminForm(ModelForm):
    pass


@admin.register(LoggedAction)
class LoggedActionAdmin(admin.ModelAdmin):
    form = LoggedActionAdminForm
    search_fields = ('user__username', 'popit_person_new_version',
                     'person', 'ip_address', 'source')
    list_filter = ('action_type',)
    list_display = ['user', 'ip_address', 'action_type',
                    'popit_person_new_version', 'person_link',
                    'created', 'updated', 'source']
    ordering = ('-created',)

    def person_link(self, o):
        if not o.person:
            return ''
        url = reverse('person-view', kwargs={'person_id': o.person.id})
        return '<a href="{0}">{1}</a>'.format(
            url,
            o.person.name,
        )
    person_link.allow_tags = True


class PartySetAdminForm(ModelForm):
    pass


@admin.register(PartySet)
class PartySetAdmin(admin.ModelAdmin):
    form = PartySetAdminForm


class ExtraFieldAdminForm(ModelForm):
    pass


@admin.register(ExtraField)
class ExtraFieldAdmin(admin.ModelAdmin):
    form = ExtraFieldAdminForm


class PersonExtraFieldValueAdminForm(ModelForm):
    pass


@admin.register(PersonExtraFieldValue)
class PersonExtraFieldValueAdmin(admin.ModelAdmin):
    form = PersonExtraFieldValueAdminForm


@admin.register(SimplePopoloField)
class SimplePopoloFieldAdmin(admin.ModelAdmin):
    list_display = ['name', 'label']


@admin.register(PostExtraElection)
class PostExtraElectionAdmin(admin.ModelAdmin):
    list_display = ['postextra', 'election', 'winner_count']
    list_filter = ('election__name', 'election__current')

    ordering = ('election', 'postextra__base__area__name')
{'fraction_non_alphanumeric': 0.10628019323671498, 'fraction_numerical': 0.0010735373054213634, 'mean_word_length': 3.969333333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4780674', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1071, 'n_words': 220}