From c5759a17c64aef0765297a324be89cfa851d023e Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Fri, 23 Apr 2010 11:37:47 -0400 Subject: [PATCH] Added the necessary files to test the generic relations --- example/settings.py | 8 +++++--- example/static/js/genericcollections.js | 20 ++++++++++++++++++++ example/urls.py | 4 ++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 example/static/js/genericcollections.js diff --git a/example/settings.py b/example/settings.py index 446d8d6..eb772bb 100644 --- a/example/settings.py +++ b/example/settings.py @@ -38,7 +38,7 @@ USE_I18N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = APP + '/static/' +MEDIA_ROOT = APP + '/media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). @@ -66,7 +66,7 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.auth.middleware.AuthenticationMiddleware', ) -ROOT_URLCONF = 'sample.urls' +ROOT_URLCONF = 'example.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". @@ -80,10 +80,12 @@ INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', + 'django.contrib.flatpages', 'categories', 'editor', 'mptt', 'simpletext', ) EDITOR_MEDIA_PATH = '/static/editor/' -CATEGORIES_ALLOW_SLUG_CHANGE = True \ No newline at end of file +CATEGORIES_ALLOW_SLUG_CHANGE = True +CATEGORIES_RELATION_MODELS = ['simpletext.simpletext','flatpages.flatpage'] \ No newline at end of file diff --git a/example/static/js/genericcollections.js b/example/static/js/genericcollections.js new file mode 100644 index 0000000..584208e --- /dev/null +++ b/example/static/js/genericcollections.js @@ -0,0 +1,20 @@ +function showGenericRelatedObjectLookupPopup(triggeringLink, ctArray) { + var realName = triggeringLink.id.replace(/^lookup_/, ''); + var name = id_to_windowname(realName); + realName = realName.replace(/object_id/, 'content_type'); + var select = document.getElementById(realName); + if (select.selectedIndex === 0) { + alert("Select a content type first."); + return false; + } + var selectedItem = select.item(select.selectedIndex).value; + var href = triggeringLink.href.replace(/#/,'../../../'+ctArray[selectedItem]+"/?t=id"); + if (href.search(/\?/) >= 0) { + href = href + '&pop=1'; + } else { + href = href + '?pop=1'; + } + var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); + win.focus(); + return false; +} \ No newline at end of file diff --git a/example/urls.py b/example/urls.py index c0f39ec..0bc8ee0 100644 --- a/example/urls.py +++ b/example/urls.py @@ -28,4 +28,8 @@ urlpatterns = patterns('', (r'^static/editor/(?P.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + '/editor/media/editor/', 'show_indexes':True}), + + (r'^static/(?P.*)$', 'django.views.static.serve', + {'document_root': ROOT_PATH + '/example/static/'}), + ) \ No newline at end of file