Skip to content

Commit 55ed790

Browse files
committed
plugin rendering adaptions
1 parent 566cc26 commit 55ed790

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
lines changed

djangocms_file/cms_plugins.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,49 @@ class FilePlugin(CMSPluginBase):
1414
render_template = 'djangocms_file/file.html'
1515
text_enabled = True
1616

17+
fieldsets = [
18+
(None, {
19+
'fields': (
20+
'file_src',
21+
'file_name',
22+
)
23+
}),
24+
(_('Advanced settings'), {
25+
'classes': ('collapse',),
26+
'fields': (
27+
('link_target', 'link_title'),
28+
'show_file_size',
29+
'attributes',
30+
)
31+
}),
32+
]
33+
1734

1835
class FolderPlugin(CMSPluginBase):
1936
model = Folder
2037
name = _('Folder')
21-
render_template = 'djangocms_file/folder.html'
2238
text_enabled = True
2339

40+
fieldsets = [
41+
(None, {
42+
'fields': (
43+
'template',
44+
'folder_src',
45+
)
46+
}),
47+
(_('Advanced settings'), {
48+
'classes': ('collapse',),
49+
'fields': (
50+
'link_target',
51+
'show_file_size',
52+
'attributes',
53+
)
54+
}),
55+
]
56+
57+
def get_render_template(self, context, instance, placeholder):
58+
return 'djangocms_file/{}/folder.html'.format(instance.template)
59+
2460

2561
plugin_pool.register_plugin(FilePlugin)
2662
plugin_pool.register_plugin(FolderPlugin)

djangocms_file/models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Enables the user to add a "File" plugin that displays a file wrapped by
44
an <anchor> tag.
55
"""
6-
import os
7-
86
from django.db import models
97
from django.conf import settings
108
from django.utils.encoding import python_2_unicode_compatible
@@ -93,8 +91,7 @@ class File(CMSPlugin):
9391
def __str__(self):
9492
if self.file_src and self.file_src.label:
9593
return self.file_src.label
96-
return str(self.file_name or self.pk)
97-
# TODO file does not exist anymore
94+
return ugettext('<file is missing>')
9895

9996

10097
@python_2_unicode_compatible
@@ -150,4 +147,6 @@ class Folder(CMSPlugin):
150147
)
151148

152149
def __str__(self):
153-
return ''
150+
if self.folder_src and self.folder_src.label:
151+
return self.folder_src.label
152+
return ugettext('<folder is missing>')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ul>
2+
<li>
3+
test
4+
</li>
5+
</ul>

djangocms_file/templates/djangocms_file/folder.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)