diff --git a/armstrong/apps/related_content/admin.py b/armstrong/apps/related_content/admin.py index 0efa62e..32d6264 100644 --- a/armstrong/apps/related_content/admin.py +++ b/armstrong/apps/related_content/admin.py @@ -2,12 +2,15 @@ from django.conf import settings from django.contrib import admin from django.contrib.contenttypes.generic import GenericTabularInline +from django.forms import widgets as django_widgets from armstrong.hatband import widgets from .models import RelatedContent from .models import RelatedType +from armstrong.hatband.utils import static_url + """ Setting ARMSTRONG_RELATED_TYPE_DEFAULT_FILTER allows you to specify @@ -17,14 +20,19 @@ class RelatedContentInlineForm(forms.ModelForm): + + class Media: + js = ( + 'hatband/js/jquery-ui-1.8.16.min.js', + ) + class Meta: widgets = { - "destination_type": forms.HiddenInput(), - "destination_id": widgets.GenericKeyWidget( + "destination_id": widgets.RawGenericKeyWidget( object_id_name="destination_id", content_type_name="destination_type", ), - "order": forms.HiddenInput(), + "order": django_widgets.HiddenInput(), } @@ -33,10 +41,11 @@ class RelatedContentInline(GenericTabularInline): ct_fk_field = "source_id" model = RelatedContent - template = "admin/edit_inline/generickey.html" - + template = 'admin/edit_inline/related_content.html' form = RelatedContentInlineForm + extra = 0 + def formfield_for_foreignkey(self, *args, **kwargs): args, kwargs = formfield_for_foreignkey_helper(self, *args, **kwargs) return super(RelatedContentInline, self).formfield_for_foreignkey( diff --git a/armstrong/apps/related_content/static/admin/related_content/related_content_inline.js b/armstrong/apps/related_content/static/admin/related_content/related_content_inline.js new file mode 100644 index 0000000..25adb7e --- /dev/null +++ b/armstrong/apps/related_content/static/admin/related_content/related_content_inline.js @@ -0,0 +1,7 @@ +(function($){ + $(document).ready(function(){ + $('.inline-related .add-row a').click(function(){ + alert('maybe?'); + }); + }); +})(django.jQuery); diff --git a/armstrong/apps/related_content/templates/admin/edit_inline/related_content.html b/armstrong/apps/related_content/templates/admin/edit_inline/related_content.html new file mode 100644 index 0000000..77de2e3 --- /dev/null +++ b/armstrong/apps/related_content/templates/admin/edit_inline/related_content.html @@ -0,0 +1,149 @@ +{% load i18n adminmedia admin_modify %} +