Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (56 sloc) 2.449 kb
# register all interesting models for search
#print "LOADING for %s" % __name__
from links import models, admin
from links import schema, LinkWrapper
from django.conf import settings
schema.register(models.ExternalLink, search_fields=admin.ExternalLinkAdmin.search_fields,
#url='url', description=lambda obj: u"%s<br />%s" % (obj.url, obj.description), metadata='description', heading='"External links"'
url='url', description = 'description',
#short_text = 'title',
heading='"External links"'
if 'cms' in settings.INSTALLED_APPS:
from cms.models import Page
from cms.admin.pageadmin import PageAdmin
class PageLinkWrapper(LinkWrapper):
#search_fields = PageAdmin.search_fields
search_fields = ['title_set__title',]
def text(self):
return self.obj.get_title()
def short_text(self):
return self.obj.get_menu_title()
def description(self):
return self.obj.get_meta_description()
def metadata(self):
ancestors = self.obj.get_cached_ancestors()
r = []
for ancestor in ancestors:
r.append(u"%s" % ancestor.get_menu_title())
return u" &raquo; ".join(r)
def heading(self):
return "Related pages"
schema.register_wrapper(Page, PageLinkWrapper)
if 'filer' in settings.INSTALLED_APPS:
from filer.models import File
from filer.admin import FileAdmin
def the_path(obj, items=[]):
items[0:0] = []
if obj.parent:
items = the_path(obj.parent, items)
return items
class FileLinkWrapper(LinkWrapper):
search_fields = ['name', 'original_filename', 'sha1', 'description']
def description(self):
obj = self.obj
if obj.folder:
s = u" &raquo; ".join(the_path(obj.folder))
s =
#return u"Folder: %s" % s
return obj.description
def heading(self):
return u"Files"
schema.register_wrapper(File, FileLinkWrapper)
# schema.register(File, FileAdmin.search_fields, title="label", description="'file_description'", heading="'Files'", url="url", #short_text = 'name'
# )
Jump to Line
Something went wrong with that request. Please try again.