Skip to content

Commit 5c1e69e

Browse files
committed
Remove deprecated dropzone.load() method
1 parent fd91344 commit 5c1e69e

File tree

4 files changed

+2
-166
lines changed

4 files changed

+2
-166
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ released date: --
77

88
WARNING: **New major upstream release (backwards incompatible!).**
99

10-
* Remove ``dropzone.load()`` method.
10+
* Remove the deprecated ``dropzone.load()`` method.
1111
* Added more options to customize messages.
1212
* Drop Python 2 support.
1313
* Add an ``id`` parameter for ``dropzone.style()`` to support

docs/basic.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ In addition to manage and load resources by yourself
5252
{{ dropzone.load_js() }}
5353
</body>
5454
55-
.. tip::
56-
There is a ``dropzone.load()`` method that was a combination of
57-
``dropzone.load_css()`` and ``dropzone.load_js()``, but we recommend not
58-
to use this method for page load performance consideration. Also,
59-
``dropzone.load()`` will be removed in the near future.
60-
6155
You can assign the version of Dropzone.js through ``version`` argument,
6256
the default value is ``5.2.0``. And, you can pass ``css_url`` and
6357
``js_url`` separately to customize resources URL.

flask_dropzone/__init__.py

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -17,144 +17,6 @@
1717

1818

1919
class _Dropzone(object):
20-
@staticmethod
21-
def load(js_url="", css_url="", version="5.9.3"):
22-
"""Load Dropzone resources with given version and init dropzone configuration.
23-
24-
.. versionchanged:: 1.4.3
25-
Added ``js_url`` and ``css_url`` parameters to pass custom resource URL.
26-
27-
.. versionchanged:: 1.4.4
28-
This method was deprecated due to inflexible. Now it's divided into three methods:
29-
1. Use ``load_css()`` to load css resources.
30-
2. Use ``load_js()`` to load js resources.
31-
3. Use ``config()`` to configure Dropzone.
32-
33-
:param js_url: The JavaScript url for Dropzone.js.
34-
:param css_url: The CSS url for Dropzone.js.
35-
:param version: The version of Dropzone.js.
36-
"""
37-
warnings.warn("The method will be removed in 2.0, see docs for more details.")
38-
js_filename = "dropzone.min.js"
39-
css_filename = "dropzone.min.css"
40-
41-
upload_multiple = current_app.config["DROPZONE_UPLOAD_MULTIPLE"]
42-
parallel_uploads = current_app.config["DROPZONE_PARALLEL_UPLOADS"]
43-
44-
if upload_multiple in [True, "true", "True", 1]:
45-
upload_multiple = "true"
46-
else:
47-
upload_multiple = "false"
48-
49-
serve_local = current_app.config["DROPZONE_SERVE_LOCAL"]
50-
size = current_app.config["DROPZONE_MAX_FILE_SIZE"]
51-
param = current_app.config["DROPZONE_INPUT_NAME"]
52-
redirect_view = current_app.config["DROPZONE_REDIRECT_VIEW"]
53-
54-
if redirect_view is not None:
55-
redirect_js = """
56-
this.on("queuecomplete", function(file) {
57-
// Called when all files in the queue finish uploading.
58-
window.location = "%s";
59-
});""" % url_for(redirect_view)
60-
else:
61-
redirect_js = ""
62-
63-
if not current_app.config["DROPZONE_ALLOWED_FILE_CUSTOM"]:
64-
allowed_type = allowed_file_extensions[
65-
current_app.config["DROPZONE_ALLOWED_FILE_TYPE"]
66-
]
67-
else:
68-
allowed_type = current_app.config["DROPZONE_ALLOWED_FILE_TYPE"]
69-
70-
max_files = current_app.config["DROPZONE_MAX_FILES"]
71-
default_message = current_app.config["DROPZONE_DEFAULT_MESSAGE"]
72-
invalid_file_type = current_app.config["DROPZONE_INVALID_FILE_TYPE"]
73-
file_too_big = current_app.config["DROPZONE_FILE_TOO_BIG"]
74-
server_error = current_app.config["DROPZONE_SERVER_ERROR"]
75-
browser_unsupported = current_app.config["DROPZONE_BROWSER_UNSUPPORTED"]
76-
max_files_exceeded = current_app.config["DROPZONE_MAX_FILE_EXCEED"]
77-
cancelUpload = current_app.config["DROPZONE_CANCEL_UPLOAD"]
78-
removeFile = current_app.config["DROPZONE_REMOVE_FILE"]
79-
cancelConfirmation = current_app.config["DROPZONE_CANCEL_CONFIRMATION"]
80-
uploadCanceled = current_app.config["DROPZONE_UPLOAD_CANCELED"]
81-
82-
timeout = current_app.config["DROPZONE_TIMEOUT"]
83-
if timeout:
84-
timeout_js = "timeout: %d," % timeout
85-
else:
86-
timeout_js = ""
87-
88-
if serve_local:
89-
js = '<script src="%s"></script>\n' % url_for(
90-
"dropzone.static", filename=js_filename
91-
)
92-
css = '<link rel="stylesheet" href="%s" type="text/css">\n' % url_for(
93-
"dropzone.static", filename=css_filename
94-
)
95-
else:
96-
js = (
97-
'<script src="https://cdn.jsdelivr.net/npm/dropzone@%s/dist/%s"></script>\n'
98-
% (version, js_filename)
99-
)
100-
css = (
101-
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dropzone@%s/dist/min/%s"'
102-
' type="text/css">\n' % (version, css_filename)
103-
)
104-
105-
if js_url:
106-
js = '<script src="%s"></script>\n' % js_url
107-
if css_url:
108-
css = '<link rel="stylesheet" href="%s" type="text/css">\n' % css_url
109-
110-
return Markup(
111-
"""
112-
%s%s<script>
113-
Dropzone.options.myDropzone = {
114-
init: function() {%s},
115-
uploadMultiple: %s,
116-
parallelUploads: %d,
117-
paramName: "%s", // The name that will be used to transfer the file
118-
maxFilesize: %d, // MB
119-
acceptedFiles: "%s",
120-
maxFiles: %s,
121-
dictDefaultMessage: "%s", // message display on drop area
122-
dictFallbackMessage: "%s",
123-
dictInvalidFileType: "%s",
124-
dictFileTooBig: "%s",
125-
dictResponseError: "%s",
126-
dictMaxFilesExceeded: "%s",
127-
dictCancelUpload: "%s",
128-
dictRemoveFile: "%s",
129-
dictCancelUploadConfirmation: "%s",
130-
dictUploadCanceled: "%s",
131-
%s // timeout
132-
};
133-
</script>
134-
"""
135-
% (
136-
css,
137-
js,
138-
redirect_js,
139-
upload_multiple,
140-
parallel_uploads,
141-
param,
142-
size,
143-
allowed_type,
144-
max_files,
145-
default_message,
146-
browser_unsupported,
147-
invalid_file_type,
148-
file_too_big,
149-
server_error,
150-
max_files_exceeded,
151-
cancelUpload,
152-
removeFile,
153-
cancelConfirmation,
154-
uploadCanceled,
155-
timeout_js,
156-
)
157-
)
15820

15921
@staticmethod
16022
def load_css(css_url=None, version="5.9.3"):

test_flask_dropzone.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,9 @@ def upload():
2424
@self.app.route('/')
2525
def index():
2626
return render_template_string('''
27-
{{ dropzone.load_css() }}\n{{ dropzone.create(action_view='upload') }}
27+
{{ dropzone.load_css() }}\n{{ dropzone.create(action='upload') }}
2828
{{ dropzone.load_js() }}\n{{ dropzone.config() }}''')
2929

30-
@self.app.route('/load')
31-
def load():
32-
return render_template_string('''
33-
{{ dropzone.load() }}\n{{ dropzone.create(action_view='upload') }}''')
34-
3530
self.context = self.app.test_request_context()
3631
self.context.push()
3732
self.client = self.app.test_client()
@@ -42,13 +37,6 @@ def tearDown(self):
4237
def test_extension_init(self):
4338
self.assertIn('dropzone', current_app.extensions)
4439

45-
def test_load(self):
46-
rv = self.dropzone.load()
47-
self.assertIn('https://cdn.jsdelivr.net/npm/dropzone@', rv)
48-
self.assertIn('dropzone.min.js', rv)
49-
self.assertIn('dropzone.min.css', rv)
50-
self.assertIn('Dropzone.options.myDropzone', rv)
51-
5240
def test_load_css(self):
5341
rv = self.dropzone.load_css()
5442
self.assertIn('dropzone.min.css', rv)
@@ -153,14 +141,6 @@ def test_render_template(self):
153141
self.assertIn('Dropzone.options.myDropzone', data)
154142
self.assertIn('<form action="/upload" method="post" class="dropzone" id="myDropzone"', data)
155143

156-
response = self.client.get('/load')
157-
data = response.get_data(as_text=True)
158-
self.assertIn('https://cdn.jsdelivr.net/npm/dropzone@', data)
159-
self.assertIn('dropzone.min.js', data)
160-
self.assertIn('dropzone.min.css', data)
161-
self.assertIn('Dropzone.options.myDropzone', data)
162-
self.assertIn('<form action="/upload" method="post" class="dropzone" id="myDropzone"', data)
163-
164144
def test_get_url(self):
165145
url1 = get_url('upload')
166146
url2 = get_url('/upload')

0 commit comments

Comments
 (0)