This repository was archived by the owner on Nov 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathcms_plugins.py
More file actions
49 lines (40 loc) · 1.46 KB
/
cms_plugins.py
File metadata and controls
49 lines (40 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from __future__ import unicode_literals
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext as _
from django.conf import settings
from django.template.loader import select_template
from .models import FilerLinkPlugin
class FilerLinkPlugin(CMSPluginBase):
module = 'Filer'
model = FilerLinkPlugin
name = _("Link")
text_enabled = True
raw_id_fields = ('page_link', )
TEMPLATE_NAME = 'cmsplugin_filer_link/plugins/link/%s.html'
render_template = 'cmsplugin_filer_link/link.html'
def render(self, context, instance, placeholder):
self.render_template = select_template((
self.TEMPLATE_NAME % instance.link_style,
'cmsplugin_filer_link/link.html',)
)
if instance.file:
link = instance.file.url
elif instance.mailto:
link = "mailto:%s" % _(instance.mailto)
elif instance.url:
link = _(instance.url)
elif instance.page_link:
link = instance.page_link.get_absolute_url()
else:
link = ""
context.update({
'link': link,
'style': instance.link_style,
'name': instance.name,
'new_window': instance.new_window,
})
return context
def icon_src(self, instance):
return settings.STATIC_URL + "cms/images/plugins/link.png"
plugin_pool.register_plugin(FilerLinkPlugin)