Skip to content

Commit b400a89

Browse files
committed
Revert "Renames File.file -> File.source to prevent issues in Django 1.9"
This reverts commit b1399d5. That change is no longer necessary, since removing the related_name has the same effect without possibly breaking existing code relying on the 'file' field. Those changes have not been release yet, so it is ok to remove the migrations.
1 parent ae770bd commit b400a89

File tree

5 files changed

+9
-75
lines changed

5 files changed

+9
-75
lines changed

djangocms_file/cms_plugins.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FilePlugin(CMSPluginBase):
1515

1616
fieldsets = [
1717
(None, {
18-
'fields': ('title', 'source', 'tooltip', 'target', )
18+
'fields': ('title', 'file', 'tooltip', 'target', )
1919
})
2020
]
2121

@@ -30,7 +30,6 @@ def icon_src(self, instance):
3030
file_icon = instance.get_icon_url()
3131
if file_icon:
3232
return file_icon
33-
return settings.STATIC_URL + u"cms/img/icons/plugins/source.png"
3433
return settings.STATIC_URL + u"cms/img/icons/plugins/file.png"
3534

3635
plugin_pool.register_plugin(FilePlugin)

djangocms_file/migrations/0003_rename_file_field_20160115_1904.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

djangocms_file/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class File(CMSPlugin):
3939
The icon search is currently performed within get_icon_url; this is
4040
probably a performance concern.
4141
"""
42-
source = models.FileField(_("source"), upload_to=get_plugin_media_path)
42+
file = models.FileField(_("file"), upload_to=get_plugin_media_path)
4343
title = models.CharField(
4444
_("title"), max_length=255, null=True, blank=True,
4545
help_text=_("Optional title to display. If not supplied, the filename "
@@ -70,9 +70,9 @@ class File(CMSPlugin):
7070
def __str__(self):
7171
if self.title:
7272
return self.title
73-
elif self.source:
73+
elif self.file:
7474
# added if, because it raised attribute error when
75-
# source wasn't defined
75+
# file wasn't defined
7676
return self.get_file_name()
7777
return "<empty>"
7878

@@ -85,10 +85,10 @@ def get_icon_url(self):
8585
return None
8686

8787
def file_exists(self):
88-
return default_storage.exists(self.source.name)
88+
return default_storage.exists(self.file.name)
8989

9090
def get_file_name(self):
91-
return os.path.basename(self.source.name)
91+
return os.path.basename(self.file.name)
9292

9393
def get_ext(self):
9494
return os.path.splitext(self.get_file_name())[1][1:].lower()

djangocms_file/south_migrations/0004_rename_file_field.py

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{% load i18n %}
2-
{% if object.source.url %}
2+
{% if object.file.url %}
33
<p class="plugin_file">
4-
<a href="{{ object.source.url }}"{% if object.target %} target="{{ object.target }}"{% endif %}{% if object.tooltip %} title="{{ object.tooltip }}"{% endif %}>
4+
<a href="{{ object.file.url }}"{% if object.target %} target="{{ object.target }}"{% endif %}{% if object.tooltip %} title="{{ object.tooltip }}"{% endif %}>
55
{% if object.get_icon_url %}<img src="{{ object.get_icon_url }}" alt="" />{% endif %}
6-
{% if object.title %}<span class="filetitle">{{ object.title }}{% else %}{{ object.get_file_name }}{% endif %} {% if object.file_exists %}<span class="filesize">({{ object.source.size|filesizeformat }})</span>{% else %}({% trans "file missing!" %}){% endif %}{% if object.title %}</span>{% endif %}
6+
{% if object.title %}<span class="filetitle">{{ object.title }}{% else %}{{ object.get_file_name }}{% endif %} {% if object.file_exists %}<span class="filesize">({{ object.file.size|filesizeformat }})</span>{% else %}({% trans "file missing!" %}){% endif %}{% if object.title %}</span>{% endif %}
77
</a>
88
</p>
99
{% endif %}

0 commit comments

Comments
 (0)