Permalink
Browse files

Added additional parameters to constuctor

  • Loading branch information...
1 parent 929b624 commit f8bd653ef2b3e1c2093c7b72ee323b07d6b81a4e @asilachev asilachev committed Jan 21, 2013
Showing with 11 additions and 2 deletions.
  1. +7 −2 django_filepicker/forms.py
  2. +4 −0 django_filepicker/models.py
@@ -14,13 +14,14 @@ class FPFieldMixin():
widget = FPFileWidget
default_mimetypes = "*/*"
- def initialize(self, apikey=None, mimetypes=None, services=None):
+ def initialize(self, apikey=None, mimetypes=None, services=None, additional_params=None):
"""
Initializes the Filepicker field.
Valid arguments:
* apikey. This string is required if it isn't set as settings.FILEPICKER_API_KEY
* mimetypes. Optional, the allowed mimetypes for files. Defaults to "*/*" (all files)
* services. Optional, the allowed services to pull from.
+ * additional_params. Optional, additional parameters to be applied.
"""
self.apikey = apikey or getattr(settings, 'FILEPICKER_API_KEY', None)
@@ -38,7 +39,7 @@ def initialize(self, apikey=None, mimetypes=None, services=None):
self.mimetypes = str(self.mimetypes)
self.services = services or getattr(settings, 'FILEPICKER_SERVICES', None)
- self.additional_params = getattr(settings, 'FILEPICKER_ADDITIONAL_PARAMS', None)
+ self.additional_params = additional_params or getattr(settings, 'FILEPICKER_ADDITIONAL_PARAMS', None)
def widget_attrs(self, widget):
attrs = {
@@ -66,11 +67,13 @@ def __init__(self, *args, **kwargs):
* apikey. This string is required if it isn't set as settings.FILEPICKER_API_KEY
* mimetypes. Optional, the allowed mimetypes for files. Defaults to "*/*" (all files)
* services. Optional, the allowed services to pull from.
+ * additional_params. Optional, additional parameters to be applied.
"""
self.initialize(
apikey=kwargs.pop('apikey', None),
mimetypes=kwargs.pop('mimetypes', None),
services=kwargs.pop('services', None),
+ additional_params=kwargs.pop('additional_params', None),
)
super(FPUrlField, self).__init__(*args, **kwargs)
@@ -83,11 +86,13 @@ def __init__(self, *args, **kwargs):
* apikey. This string is required if it isn't set as settings.FILEPICKER_API_KEY
* mimetypes. Optional, the allowed mimetypes for files. Defaults to "*/*" (all files)
* services. Optional, the allowed services to pull from.
+ * additional_params. Optional, additional parameters to be applied.
"""
self.initialize(
apikey=kwargs.pop('apikey', None),
mimetypes=kwargs.pop('mimetypes', None),
services=kwargs.pop('services', None),
+ additional_params=kwargs.pop('additional_params', None),
)
super(FPFileField, self).__init__(*args, **kwargs)
@@ -14,10 +14,12 @@ def __init__(self, *args, **kwargs):
* apikey. This string is required if it isn't set as settings.FILEPICKER_API_KEY
* mimetypes. Optional, the allowed mimetypes for files. Defaults to "*/*" (all files)
* services. Optional, the allowed services to pull from.
+ * additional_params. Optional, additional parameters to be applied.
"""
self.apikey = kwargs.pop("apikey", None)
self.mimetypes = kwargs.pop("mimetypes", None)
self.services = kwargs.pop("services", None)
+ self.additional_params=kwargs.pop("additional_params", None)
super(FPFileField, self).__init__(*args, **kwargs)
@@ -34,6 +36,8 @@ def formfield(self, **kwargs):
defaults['mimetypes'] = self.mimetypes
if self.services:
defaults['services'] = self.services
+ if self.additional_params:
+ defaults['additional_params'] = self.additional_params
defaults.update(kwargs)
return super(FPFileField, self).formfield(**defaults)

0 comments on commit f8bd653

Please sign in to comment.