Skip to content

Commit

Permalink
Merge pull request #466 from claudep/issue464
Browse files Browse the repository at this point in the history
Fixes #464 - Do not include 'upload_attachment' in widget settings if deactivated
  • Loading branch information
Dennis Suitters authored Feb 16, 2024
2 parents 8b17863 + d43535a commit 5dd48be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions django_summernote/test_django_summernote.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def test_attachment_require_authentication(self):

@patch('django_summernote.views.logger')
def test_attachment_disable_attachment(self, mock_logging):
from django_summernote.widgets import SummernoteWidget

url = reverse('django_summernote-upload_attachment')
self.summernote_config['disable_attachment'] = True

Expand All @@ -279,6 +281,8 @@ def test_attachment_disable_attachment(self, mock_logging):
self.assertDictEqual(response.json(), {"status": "false", "message": "Attachment module is disabled"})
self.assertTrue(mock_logging.error.called)

self.assertNotIn('upload_attachment', SummernoteWidget().summernote_settings()['url'])

self.summernote_config['disable_attachment'] = False

@patch('django_summernote.views.logger')
Expand Down
3 changes: 2 additions & 1 deletion django_summernote/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def summernote_settings(self):
'lang': lang,
'url': {
'language': static('summernote/lang/summernote-' + lang + '.min.js'),
'upload_attachment': reverse('django_summernote-upload_attachment'),
},
})
if not get_config().get('disable_attachment', False):
summernote_settings['url']['upload_attachment'] = reverse('django_summernote-upload_attachment')
return summernote_settings

def value_from_datadict(self, data, files, name):
Expand Down

0 comments on commit 5dd48be

Please sign in to comment.