Skip to content

Commit

Permalink
Merge 44a2a2c into 51196fd
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Feb 4, 2015
2 parents 51196fd + 44a2a2c commit 23442ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
13 changes: 9 additions & 4 deletions filer/fields/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,17 @@ def __init__(self, **kwargs):
# We hard-code the `to` argument for ForeignKey.__init__
if "to" in kwargs.keys():
old_to = kwargs.pop("to")
msg = "%s can only be a ForeignKey to %s; %s passed" % (
self.__class__.__name__, self.default_model_class.__name__, old_to
dfl = "%s.%s" % (
self.default_model_class._meta.app_label,
self.default_model_class.__name__
)
warnings.warn(msg, SyntaxWarning)
if old_to != dfl:
msg = "%s can only be a ForeignKey to %s; %s passed" % (
self.__class__.__name__, self.default_model_class.__name__, old_to
)
warnings.warn(msg, SyntaxWarning)
kwargs['to'] = self.default_model_class
return super(FilerFileField, self).__init__(**kwargs)
super(FilerFileField, self).__init__(**kwargs)

def formfield(self, **kwargs):
# This is a fairly standard way to set up some defaults
Expand Down
14 changes: 10 additions & 4 deletions filer/fields/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class AdminFolderWidget(ForeignKeyRawIdWidget):
choices = None
input_type = 'hidden'
is_hidden = False

def render(self, name, value, attrs=None):
obj = self.obj_for_value(value)
Expand Down Expand Up @@ -109,12 +110,17 @@ def __init__(self, **kwargs):
# We hard-code the `to` argument for ForeignKey.__init__
if "to" in kwargs.keys():
old_to = kwargs.pop("to")
msg = "%s can only be a ForeignKey to %s; %s passed" % (
self.__class__.__name__, self.default_model_class.__name__, old_to
dfl = "%s.%s" % (
self.default_model_class._meta.app_label,
self.default_model_class.__name__
)
warnings.warn(msg, SyntaxWarning)
if old_to != dfl:
msg = "%s can only be a ForeignKey to %s; %s passed" % (
self.__class__.__name__, self.default_model_class.__name__, old_to
)
warnings.warn(msg, SyntaxWarning)
kwargs['to'] = self.default_model_class
return super(FilerFolderField, self).__init__(**kwargs)
super(FilerFolderField, self).__init__(**kwargs)

def formfield(self, **kwargs):
# This is a fairly standard way to set up some defaults
Expand Down
5 changes: 3 additions & 2 deletions filer/fields/multistorage_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def __init__(self, verbose_name=None, name=None,
storages=None, thumbnail_storages=None, thumbnail_options=None, **kwargs):
if 'upload_to' in kwargs:
upload_to = kwargs.pop("upload_to")
warnings.warn("MultiStorageFileField can handle only File objects;"
"%s passed" % upload_to, SyntaxWarning)
if upload_to != generate_filename_multistorage:
warnings.warn("MultiStorageFileField can handle only File objects;"
"%s passed" % upload_to, SyntaxWarning)
self.storages = storages or STORAGES
self.thumbnail_storages = thumbnail_storages or THUMBNAIL_STORAGES
self.thumbnail_options = thumbnail_options or THUMBNAIL_OPTIONS
Expand Down

0 comments on commit 23442ea

Please sign in to comment.