summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-07-20 09:04:00 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-07-20 09:04:00 (GMT)
commitd2ddec17ac196c2a090875d081757d195b5190e1 (patch)
treee0463dff4b2754d24be1c02a463b1e04b13cd6f8 /program
parentfd2b1751a5b0b334fd5f280ba54e30ed81c96c08 (diff)
exclude self as show predecessor
Diffstat (limited to 'program')
-rw-r--r--program/admin.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/program/admin.py b/program/admin.py
index fee5d4e..bb47ca2 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -98,13 +98,18 @@ class ShowAdmin(admin.ModelAdmin):
search_fields = ('name', 'short_description', 'description')
fields = (
'predecessor', 'broadcastformat', 'name', 'slug', 'image', 'image_enabled', 'short_description', 'description',
- 'email', 'website', 'cba_series_id', 'automation_id', 'hosts', 'owners', 'showinformation', 'showtopic',
+ 'email', 'website', 'automation_id', 'hosts', 'owners', 'showinformation', 'showtopic',
'musicfocus',
)
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
- if db_field.name == 'predecessor':
- kwargs['queryset'] = Show.objects.exclude(pk=352) # FIXME!
+ try:
+ show_id = int(request.get_full_path().split('/')[-2])
+ except ValueError:
+ show_id = None
+
+ if db_field.name == 'predecessor' and show_id:
+ kwargs['queryset'] = Show.objects.exclude(pk=show_id)
return super(ShowAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)