Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Make martor upload button part of MARTOR_ENABLE_CONFIGS #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions martor/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


class MartorWidget(forms.Textarea):
UPLOADS_ENABLED = False

def render(self, name, value, attrs=None, renderer=None, **kwargs):
# Make the settings the default attributes to pass
attributes_to_pass = {
Expand All @@ -38,18 +36,20 @@ def render(self, name, value, attrs=None, renderer=None, **kwargs):
# being part of the render chain.
attributes_to_pass.update(self.attrs)

widget = super(MartorWidget, self).render(name, value, attributes_to_pass)
widget = super(MartorWidget, self).render(
name, value, attributes_to_pass)

template = get_template('martor/editor.html')
emoji_enabled = MARTOR_ENABLE_CONFIGS.get('emoji') == 'true'
mentions_enabled = MARTOR_ENABLE_CONFIGS.get('mention') == 'true'
uploads_enabled = MARTOR_ENABLE_CONFIGS.get('uploads') == 'true'

return template.render({
'martor': widget,
'field_name': name,
'emoji_enabled': emoji_enabled,
'mentions_enabled': mentions_enabled,
'uploads_enabled': self.UPLOADS_ENABLED,
'uploads_enabled': uploads_enabled,
})

class Media:
Expand Down