Skip to content

Commit

Permalink
Add FileNode meta info to changelist and related lookup popup
Browse files Browse the repository at this point in the history
  • Loading branch information
samluescher committed Feb 18, 2016
1 parent 0385a48 commit c85277e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion media_tree/admin/filenode_admin.py
Expand Up @@ -25,6 +25,7 @@
from django.contrib.admin.options import csrf_protect_m
from django.template.loader import render_to_string
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.html import escape
from django.template.defaultfilters import filesizeformat
from django.db import models
from django.http import HttpResponseBadRequest
Expand Down Expand Up @@ -95,7 +96,12 @@ def node_preview(self, node, icons_only=False):
'preview_file': node.get_preview_file(default_name='_folder_expanded'),
'class': 'expanded-folder hidden'
}).strip())
return preview

meta = '<link class="meta" rel="alternate" data-id="%s" type="%s" href="%s" data-name="%s" data-alt="%s" data-caption="%s">' % (
node.pk, FileNode.get_mimetype(node.file.path) if node.file else '', escape(node.file.url) if node.file else '',
escape(node), escape(node.alt), escape(node.get_caption_formatted()))

return "%s%s" % (preview, meta)
node_preview.short_description = ''
node_preview.allow_tags = True

Expand Down
2 changes: 2 additions & 0 deletions media_tree/static/media_tree/js/filenode_changelist.js
Expand Up @@ -18,6 +18,8 @@ jQuery(function($) {
$targetPreview.replaceWith($preview);
$targetName.replaceWith($name);
}

window.selectedMeta = $trigger.find('link.meta')[0];
_onclick();
});
});
Expand Down

0 comments on commit c85277e

Please sign in to comment.