def displayable_links_js(request):
 links = []
 if (u'mezzanine.pages' in settings.INSTALLED_APPS):
  from mezzanine.pages.models import Page
  is_page = (lambda obj: isinstance(obj, Page))
 else:
  is_page = (lambda obj: False)
 for (url, obj) in Displayable.objects.url_map(for_user=request.user).items():
  title = getattr(obj, u'titles', obj.title)
  real = hasattr(obj, u'id')
  page = is_page(obj)
  if real:
   verbose_name = (_(u'Page') if page else obj._meta.verbose_name)
   title = (u'%s: %s' % (verbose_name, title))
  links.append((((not page) and real), {u'title': str(title), u'value': url}))
 sorted_links = sorted(links, key=(lambda link: (link[0], link[1][u'value'])))
 return HttpResponse(dumps([link[1] for link in sorted_links]))

def displayable_links_js ( request ) : links = [ ] if ( u'mezzanine.pages' in settings . INSTALLED_APPS ) : from mezzanine . pages . models import Page is_page = ( lambda obj : isinstance ( obj , Page ) ) else : is_page = ( lambda obj : False ) for ( url , obj ) in Displayable . objects . url_map ( for_user = request . user ) . items ( ) : title = getattr ( obj , u'titles' , obj . title ) real = hasattr ( obj , u'id' ) page = is_page ( obj ) if real : verbose_name = ( _ ( u'Page' ) if page else obj . _meta . verbose_name ) title = ( u'%s: %s' % ( verbose_name , title ) ) links . append ( ( ( ( not page ) and real ) , { u'title' : str ( title ) , u'value' : url } ) ) sorted_links = sorted ( links , key = ( lambda link : ( link [ 0 ] , link [ 1 ] [ u'value' ] ) ) ) return HttpResponse ( dumps ( [ link [ 1 ] for link in sorted_links ] ) )
renders a list of url/title pairs for all displayable subclass instances into json thats used to populate a list of links in tinymce .