Carl Meyer avatar Carl Meyer committed 517d778 Draft

Remove ADMINFILES_MEDIA_URL, just use STATIC_URL.

Comments (0)

Files changed (7)

 
 - BACKWARDS-INCOMPATIBLE: Django versions prior to 1.4 are no longer tested or supported.
 
+- BACKWARDS-INCOMPATIBLE: Removed the ``ADMINFILES_MEDIA_URL`` setting, use
+  ``STATIC_URL`` everywhere for static assets. Thanks Rudolph Froger for the
+  nudge.
+
 - Updated to most recent sorl-thumbnail. Thanks Svyatoslav Bulbakha.
 
 - Added Russian translation. Thanks Svyatoslav Bulbakha.
     2. Run ``python manage.py syncdb`` to to create the adminfiles database
        tables.
 
-    3. Make the contents of the ``adminfiles/media/adminfiles``
-       directory available at ``MEDIA_URL/adminfiles`` (or
-       ``ADMINFILES_MEDIA_URL/adminfiles/``, see `ADMINFILES_MEDIA_URL`_). 
-       This can be done by through your webserver configuration, via an app
-       such as `django-staticfiles`_, or by copying the files or making a
+    3. Make the contents of the ``adminfiles/static/adminfiles`` directory
+       available at ``STATIC_URL/adminfiles``.  This can be done by through
+       your webserver configuration, via an app such as
+       ``django.contrib.staticfiles``, or by copying the files or making a
        symlink.
 
     4. Add ``url(r'^adminfiles/', include('adminfiles.urls'))`` in your
 images with alpha transparency aren't broken when thumbnailed in the
 adminfiles file-picker.
 
-.. _django-staticfiles: http://pypi.python.org/pypi/django-staticfiles
 
 FilePickerAdmin
 ===============
 insertion option, and the second entry is a dictionary of options to
 be added to the inserted file reference.
 
-ADMINFILES_MEDIA_URL
---------------------
-
-Some projects separate user-uploaded media at ``MEDIA_URL`` from
-static assets. If you keep static assets at a URL other than
-``MEDIA_URL``, just set ``ADMINFILES_MEDIA_URL`` to that URL, and make
-sure the contents of the ``adminfiles/media/adminfiles`` directory are
-available at ``ADMINFILES_MEDIA_URL/adminfiles/``.
 
 ADMINFILES_UPLOAD_TO
 --------------------
 JQUERY_URL
 ----------
 
-``django-adminfiles`` requires the jQuery Javascript library.  For Django
-versions 1.2 or later, ``django-adminfiles`` by default uses the version of
-jQuery included with the Django admin.  For older versions, by default
-``django-adminfiles`` links to the most recent minor version of jQuery 1.4
-available at ajax.googleapis.com (via the URL
-``http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js``).
+``django-adminfiles`` requires the jQuery Javascript library.  By default,
+``django-adminfiles`` uses the latest version of jQuery 1.4 hosted by Google,
+via the URL http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js.
 
-If you wish to use a different version of jQuery, or host it yourself, set
-the JQUERY_URL setting.  For example::
+If you wish to use a different version of jQuery, or host it yourself, set the
+``JQUERY_URL`` setting. ``JQUERY_URL`` can be absolute or relative; if relative
+it is relative to ``STATIC_URL``. For example::
 
     JQUERY_URL = 'jquery.min.js'
 
-This will use the jQuery available at MEDIA_URL/jquery.min.js. Note
-that a relative ``JQUERY_URL`` is always relative to ``MEDIA_URL``, it
-does not use ``ADMINFILES_MEDIA_URL``.
-
+This will use the jQuery available at ``STATIC_URL/jquery.min.js``.

adminfiles/admin.py

 from django.contrib import admin
 
 from adminfiles.models import FileUpload
-from adminfiles.settings import ADMINFILES_MEDIA_URL, JQUERY_URL
+from adminfiles.settings import JQUERY_URL, STATIC_URL
 from adminfiles.listeners import register_listeners
 
 class FileUploadAdmin(admin.ModelAdmin):
     prepopulated_fields = {'slug': ('title',)}
 # uncomment for snipshot photo editing feature
 #    class Media:
-#        js = (JQUERY_URL, posixpath.join(ADMINFILES_MEDIA_URL,
+#        js = (JQUERY_URL, posixpath.join(STATIC_URL,
 #                                         'photo-edit.js'))
     def response_change(self, request, obj):
         if request.POST.has_key("_popup"):
         return super(FileUploadAdmin, self).response_add(request,
                                                          *args,
                                                          **kwargs)
-            
-        
+
+
 class FilePickerAdmin(admin.ModelAdmin):
     adminfiles_fields = []
 
     def __init__(self, *args, **kwargs):
         super(FilePickerAdmin, self).__init__(*args, **kwargs)
         register_listeners(self.model, self.adminfiles_fields)
-    
+
     def formfield_for_dbfield(self, db_field, **kwargs):
         field = super(FilePickerAdmin, self).formfield_for_dbfield(
             db_field, **kwargs)
         return field
 
     class Media:
-        js = [JQUERY_URL, posixpath.join(ADMINFILES_MEDIA_URL, 'adminfiles/model.js')]
+        js = [JQUERY_URL, posixpath.join(STATIC_URL, 'adminfiles/model.js')]
 
 admin.site.register(FileUpload, FileUploadAdmin)

adminfiles/settings.py

 import posixpath
 
-import django
 from django.conf import settings
 from django.utils.translation import ugettext_lazy as _
 
 JQUERY_URL = getattr(settings, 'JQUERY_URL',
                      'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js')
 
+STATIC_URL = settings.STATIC_URL
+
 if JQUERY_URL and not ((':' in JQUERY_URL) or (JQUERY_URL.startswith('/'))):
-    JQUERY_URL = posixpath.join(settings.MEDIA_URL, JQUERY_URL)
-
-ADMINFILES_MEDIA_URL = getattr(settings, 'ADMINFILES_MEDIA_URL',
-                               settings.MEDIA_URL)
+    JQUERY_URL = posixpath.join(STATIC_URL, JQUERY_URL)
 
 ADMINFILES_UPLOAD_TO = getattr(settings, 'ADMINFILES_UPLOAD_TO', 'adminfiles')
 

adminfiles/templates/adminfiles/uploader/base.html

 {% load thumbnail %}
 {% load i18n %}
 {% block extrastyle %}
-    <link rel="stylesheet" href="{{ ADMINFILES_MEDIA_URL }}adminfiles/adminfiles.css" type="text/css" media="screen" charset="utf-8" />
+    <link rel="stylesheet" href="{{ STATIC_URL }}adminfiles/adminfiles.css" type="text/css" media="screen" charset="utf-8" />
     <script type="text/javascript" src="{{ JQUERY_URL }}"></script>
     <script type="text/javascript" charset="utf-8">
         var FIELD = parent.document.getElementById('{{field_id}}');
         var START = "{{ ADMINFILES_REF_START|safe }}";
         var END = "{{ ADMINFILES_REF_END|safe }}";
     </script>
-    <script type="text/javascript" src="{{ ADMINFILES_MEDIA_URL }}adminfiles/adminfiles.js"></script>
+    <script type="text/javascript" src="{{ STATIC_URL }}adminfiles/adminfiles.js"></script>
 
 {% endblock %}
 {% block bodyclass %}adminfiles{% endblock %}
     <a href="{% url "admin:adminfiles_fileupload_add" %}" class="addlink" id="add_id_uploads" onclick="return showAddUploadPopup(this);">{% trans "Upload" %}</a>
   </li>
   <li>
-    <a id="refresh" href="#"><img src="{{ADMINFILES_MEDIA_URL}}adminfiles/icon_refreshlink.gif" /> {% trans "Refresh" %}</a>
+    <a id="refresh" href="#"><img src="{{STATIC_URL}}adminfiles/icon_refreshlink.gif" /> {% trans "Refresh" %}</a>
   </li>
 </div>
 

adminfiles/views.py

-import urllib, urlparse, datetime
+import urllib
 
-from django.shortcuts import render_to_response
-from django.http import HttpResponse, Http404
+from django.http import HttpResponse
 from django.conf import settings as django_settings
-from django.template import RequestContext
 from django.core.urlresolvers import reverse
-from django.core.exceptions import ImproperlyConfigured
 from django.utils.translation import ugettext_lazy as _
-from django.views.generic import View, TemplateView
+from django.views.generic import TemplateView
 
 from adminfiles.models import FileUpload
 from adminfiles import settings
             'browsers': get_enabled_browsers(),
             'field_id': self.request.GET['field'],
             'field_type': self.request.GET.get('field_type', 'textarea'),
-            'ADMINFILES_MEDIA_URL': settings.ADMINFILES_MEDIA_URL,
             'ADMINFILES_REF_START': settings.ADMINFILES_REF_START,
             'ADMINFILES_REF_END': settings.ADMINFILES_REF_END,
             'JQUERY_URL': settings.JQUERY_URL

test_project/settings.py

     }
 }
 
-STATIC_URL = ADMINFILES_MEDIA_URL = '/static/'
+STATIC_URL = '/static/'
 STATIC_ROOT = os.path.join(BASE, 'static')
 MEDIA_ROOT = os.path.join(BASE, 'media')
 MEDIA_URL = '/media/'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.