Пример #1
0
def content_media_urls(*paths):
    """
    Prefix the list of paths with the ``CONTENT_MEDIA_URL`` setting for 
    internally hosted JS and CSS files.
    """
    media_url = CONTENT_MEDIA_URL.strip("/")
    return ["/%s/%s" % (media_url, path) for path in paths]
Пример #2
0
from django.db.models import AutoField
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from mezzanine.settings import CONTENT_MEDIA_URL
from mezzanine.core.forms import OrderableAdminForm
from mezzanine.core.models import HtmlField


media_url = CONTENT_MEDIA_URL.strip("/")
content_media = lambda files: ["/%s/%s" % (media_url, f) for f in files]

# Build the list of admin JS file for ``Displayable`` models.
# For >= Django 1.2 include a backport of the collapse js which targets
# earlier versions of the admin.
displayable_js = ["js/tinymce_setup.js", "js/jquery-1.4.2.min.js",
    "js/keywords_field.js"]
from django import VERSION
if not (VERSION[0] <= 1 and VERSION[1] <= 1):
    displayable_js.append("js/collapse_backport.js")
displayable_js = content_media(displayable_js)
displayable_js.insert(0, "/media/admin/tinymce/jscripts/tiny_mce/tiny_mce.js")

orderable_js = content_media(["js/jquery-1.4.2.min.js",
    "js/jquery-ui-1.8.1.custom.min.js", "js/orderable_inline.js"])


class DisplayableAdmin(admin.ModelAdmin):
    """
    Admin class for subclasses of the abstract ``Displayable`` model.
Пример #3
0
from django.contrib import admin
from django.contrib.admin.sites import NotRegistered
from django.views.generic.simple import direct_to_template

from mezzanine.settings import ADMIN_REMOVAL, CONTENT_MEDIA_PATH, \
    CONTENT_MEDIA_URL

urlpatterns = patterns("mezzanine.core.views",
    url("^admin_keywords_submit/$", "admin_keywords_submit",
        name="admin_keywords_submit"),
    url("^edit/$", "edit", name="edit"),
    url("^search/$", "search", name="search"),
)

urlpatterns += patterns("",
    ("^%s/(?P<path>.*)$" % CONTENT_MEDIA_URL.strip("/"),
        "django.views.static.serve", {'document_root': CONTENT_MEDIA_PATH}),
)

# Remove unwanted models from the admin that are installed by default with
# third-party apps.
for model in ADMIN_REMOVAL:
    try:
        model = tuple(model.rsplit(".", 1))
        exec "from %s import %s" % model
    except ImportError:
        pass
    else:
        try:
            admin.site.unregister(eval(model[1]))
        except NotRegistered: