Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Adding missing blank to some fields, allowing admin to work, adding a…
Browse files Browse the repository at this point in the history
…dmin for protocol parts, optmizing admin parts count
  • Loading branch information
alonisser committed Oct 30, 2016
1 parent 1e7b3dd commit dc75644
Show file tree
Hide file tree
Showing 3 changed files with 326 additions and 10 deletions.
21 changes: 17 additions & 4 deletions committees/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.generic import GenericTabularInline
from django.db.models import Q
from django.db.models import Q, Count
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin

from video.models import Video
from models import Committee, CommitteeMeeting, Topic
from models import Committee, CommitteeMeeting, Topic, ProtocolPart
from links.models import Link
from django.utils.translation import ugettext_lazy as _
from mks.utils import get_all_mk_names
Expand Down Expand Up @@ -78,7 +78,7 @@ def queryset(self, request, queryset):

class CommitteeMeetingAdmin(ImportExportModelAdmin):
ordering = ('-date',)
list_display = ('__unicode__', 'date', 'committee_type', 'protocol_parts')
list_display = ('id', '__unicode__', 'date', 'committee_type', 'protocol_parts')
list_filter = ('committee', 'committee__type', MissingProtocolListFilter)
search_fields = ['id', 'topics']
actions = ['redownload_and_reparse_protocol', 'reparse_protocol', 'update_metadata_from_dataservice']
Expand All @@ -87,7 +87,11 @@ def committee_type(self, obj):
return obj.committee.type

def protocol_parts(self, obj):
return obj.parts.all().count()
return obj.num_parts

def get_queryset(self, request):
qs = super(CommitteeMeetingAdmin, self).get_queryset(request)
return qs.annotate(num_parts=Count('parts'))

def redownload_and_reparse_protocol(self, request, qs):
mks, mk_names = get_all_mk_names()
Expand All @@ -106,9 +110,18 @@ def update_metadata_from_dataservice(self, request, qs):
[cm.update_from_dataservice() for cm in qs]
self.message_user(request, "successfully updated %s meetings" % qs.count())


admin.site.register(CommitteeMeeting, CommitteeMeetingAdmin)


class ProtocolPartsAdmin(ImportExportModelAdmin):
search_fields = ('id', 'meeting__pk', 'header', 'body')
list_display = ('id', 'meeting', 'header')


admin.site.register(ProtocolPart, ProtocolPartsAdmin)


class LinksTable(GenericTabularInline):
model = Link
ct_field = 'content_type'
Expand Down
Loading

0 comments on commit dc75644

Please sign in to comment.