Skip to content

Commit

Permalink
Added support for events in admin (fix#4005)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardinho committed Mar 11, 2013
1 parent e2a92fd commit 41c0660
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
32 changes: 18 additions & 14 deletions committees/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,48 @@
from video.models import Video
from models import *


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']
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 EventsTable(GenericTabularInline):
model = Event
ct_field='which_type'
ct_fk_field='which_pk'

class CommitteeAdmin(admin.ModelAdmin):
ordering = ('name',)
inlines = (CommitteeRelatedVideosInline, EventsTable)
ordering = ('name', )
inlines = (CommitteeRelatedVideosInline, )


admin.site.register(Committee, CommitteeAdmin)


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


admin.site.register(CommitteeMeeting, CommitteeMeetingAdmin)


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


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


admin.site.register(Topic, TopicAdmin)
9 changes: 9 additions & 0 deletions events/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin
from events.models import Event


class EventAdmin(admin.ModelAdmin):
pass


admin.site.register(Event, EventAdmin)

0 comments on commit 41c0660

Please sign in to comment.