Skip to content

Commit e09cfca

Browse files
committed
Add Filer prefix to django-filer contents
1 parent 7e032ed commit e09cfca

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

feincms/contents.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class MediaFileContentInline(FeinCMSInline):
162162

163163
class ContentWithFilerFile(models.Model):
164164
"""
165-
MediaFile Content for use with Django-Filer.
165+
File content
166166
"""
167167
feincms_item_editor_inline = MediaFileContentInline
168168

@@ -179,7 +179,7 @@ def render(self, **kwargs):
179179
'content/filer/default.html',
180180
], ctx, context_instance=kwargs.get('context'))
181181

182-
class FileContent(ContentWithFilerFile):
182+
class FilerFileContent(ContentWithFilerFile):
183183
mediafile = FilerFileField(verbose_name=_('file'), related_name='+')
184184
file_type = 'file'
185185
type = 'download'
@@ -189,16 +189,16 @@ class Meta:
189189
verbose_name = _('file')
190190
verbose_name_plural = _('files')
191191

192-
class ImageContent(ContentWithFilerFile):
192+
class FilerImageContent(ContentWithFilerFile):
193193
"""
194194
Create a media file content as follows::
195195
196-
from feincms.content.medialibrary.v2 import MediaFileContent
197-
Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
196+
from feincms.contents import FilerImageContent
197+
Page.create_content_type(FilerImageContent, TYPE_CHOICES=(
198198
('inline', _('Default')),
199199
('lightbox', _('Lightbox')),
200200
('whatever', _('Whatever')),
201-
))
201+
))
202202
203203
For a media file of type 'image' and type 'lightbox', the following
204204
templates are tried in order:

feincms/management/commands/medialibrary_to_filer.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
from django.core.management.base import NoArgsCommand
55
from django.contrib.auth.models import User
66

7-
from feincms.contents import MediaFileContent, FileContent, ImageContent
7+
from feincms.contents import (
8+
MediaFileContent, FilerFileContent, FilerImageContent,
9+
)
810
from feincms.module.medialibrary.models import MediaFile
911
from feincms.module.page.models import Page
1012

1113
from filer.models import File, Image
1214

1315

1416
PageMediaFileContent = Page.content_type_for(MediaFileContent)
15-
PageFileContent = Page.content_type_for(FileContent)
16-
PageImageContent = Page.content_type_for(ImageContent)
17+
PageFilerFileContent = Page.content_type_for(FilerFileContent)
18+
PageFilerImageContent = Page.content_type_for(FilerImageContent)
1719

1820

19-
assert (PageMediaFileContent and PageFileContent and PageImageContent),\
20-
'Not all required models available'
21+
assert all((
22+
PageMediaFileContent,
23+
PageFilerFileContent,
24+
PageFilerImageContent)), 'Not all required models available'
2125

2226

2327
class Command(NoArgsCommand):
@@ -30,7 +34,7 @@ def handle_noargs(self, **options):
3034

3135
for i, mediafile in enumerate(MediaFile.objects.order_by('pk')):
3236
model = Image if mediafile.type == 'image' else File
33-
content_model = PageImageContent if mediafile.type == 'image' else PageFileContent # noqa
37+
content_model = PageFilerImageContent if mediafile.type == 'image' else PageFilerFileContent # noqa
3438

3539
filerfile = model.objects.create(
3640
owner=user,

0 commit comments

Comments
 (0)