<commit_before>from django.contrib.contenttypes.generic import GenericTabularInline
from knesset.committees.models import *

from django.contrib import admin

class CommitteeAdmin(admin.ModelAdmin):
    ordering = ('name',)
admin.site.register(Committee, CommitteeAdmin)

class CommitteeMeetingAdmin(admin.ModelAdmin):
    ordering = ('-date',)
admin.site.register(CommitteeMeeting, CommitteeMeetingAdmin)

class LinksTable(GenericTabularInline):
    model = Link
    ct_field='content_type'
    ct_fk_field='object_pk'

class EventsTable(GenericTabularInline):
    model = Event
    ct_field='which_type'
    ct_fk_field='which_pk'

class TopicAdmin(admin.ModelAdmin):
    ordering = ('-created',)
    inlines = [
        LinksTable,
        EventsTable,
    ]

admin.site.register(Topic, TopicAdmin)
<commit_msg>added support for committee videos in admin<commit_after>from django.contrib.contenttypes.generic import GenericTabularInline
from knesset.committees.models import *
from knesset.video.models import Video
from django.db.models import Q

from django.contrib import admin

class CommitteeRelatedVideosInline(generic.GenericTabularInline):
    model = Video
    ct_fk_field = 'object_pk'
    can_delete = False
    fields = ['title','description','embed_link','group','hide']
    ordering = ['group','-published']
    readonly_fields = ['title','description','embed_link','group']
    extra = 0
    def queryset(self, request):
        qs = super(CommitteeRelatedVideosInline, self).queryset(request)
        qs = qs.filter(Q(hide=False) | Q(hide=None))
        return qs

class CommitteeAdmin(admin.ModelAdmin):
    ordering = ('name',)
    inlines = (CommitteeRelatedVideosInline,)
admin.site.register(Committee, CommitteeAdmin)

class CommitteeMeetingAdmin(admin.ModelAdmin):
    ordering = ('-date',)
admin.site.register(CommitteeMeeting, CommitteeMeetingAdmin)

class LinksTable(GenericTabularInline):
    model = Link
    ct_field='content_type'
    ct_fk_field='object_pk'

class EventsTable(GenericTabularInline):
    model = Event
    ct_field='which_type'
    ct_fk_field='which_pk'

class TopicAdmin(admin.ModelAdmin):
    ordering = ('-created',)
    inlines = [
        LinksTable,
        EventsTable,
    ]

admin.site.register(Topic, TopicAdmin)

{'fraction_non_alphanumeric': 0.1073471183457985, 'fraction_numerical': 0.0004399472063352398, 'mean_word_length': 4.71356783919598, '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': '7636557', 'n_tokens_mistral': 705, 'n_tokens_neox': 689, 'n_words': 131}