Skip to content

Conversation

@cruz-evan
Copy link

Fixes an error where navigating to the upload page results in a javascript "unexpected string error" error and causing the upload button to not appear on the page. Since mark_safe causes all of the values in the extentions to become unicode this error happens.

Original django-filebrowser 3.7.x does not have mark-safe on the get_file_extentions function.
https://github.com/sehmaschine/django-filebrowser/blob/stable/3.7.x/filebrowser/templatetags/fb_tags.py

-Similar implementation to Django 2.1 function json_script
-Fixes the problem where the upload button would not appear if the list had unicode data inside

@DylanYoung
Copy link

DylanYoung commented Jun 10, 2019

@cruz-evan Looks like there's a test that needs fixing (quotes are now reversed):

FAIL: test_get_filtered (tests.test_templatetags.GetFileExtensionsTemplateTagTests)

Traceback (most recent call last):
File "/home/travis/build/smacker/django-filebrowser-no-grappelli/tests/test_templatetags.py", line 21, in test_get_filtered
"['.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff']"
AssertionError: '[".jpg", ".jpeg", ".gif", ".png", ".tif", ".tiff"]' != "['.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff']"`

@cruz-evan cruz-evan force-pushed the json_for_script_function branch from 44a8be0 to 0a10cb9 Compare June 10, 2019 18:46
…HTML and XML

-Similar implementation to Django 2.1 function json_script
-Fixes the problem where the upload button would not appear if the list had unicode data inside
@cruz-evan cruz-evan force-pushed the json_for_script_function branch from 0a10cb9 to 2aa42f4 Compare June 11, 2019 18:23
'.tif', '.tiff', '.mp3', '.mp4', '.wav', '.aiff', '.midi', '.m4p', '.m4v', '.webm'
]))

def test_get_filtered(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cruz-evan If you unify this with the way the above test is written (as in our fork), then you don't need to worry about these small formatting differences. Probably it should use json.loads instead of eval, since this is the context wherein we hit the issue that necessitated this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants