Guilherme Gondim committed c72c873

take out reverse() from __init__ to avoid a bug

Comments (0)

Files changed (1)


 from django.conf import settings
-OPTIONS = getattr(settings, 'REDACTOR_OPTIONS', {})
+DEFAULT_OPTIONS = getattr(settings, 'REDACTOR_OPTIONS', {})
 INIT_JS = """<script type="text/javascript">
     def __init__(self, *args, **kwargs):
         super(RedactorEditor, self).__init__(*args, **kwargs)
         self.upload_to = kwargs.pop('upload_to', '')
-        self.options = OPTIONS.copy()
-        self.options.update(kwargs.pop('redactor_options', {}))
-        self.options.update({
+        self.user_options = kwargs.pop('redactor_options', {})
+    def get_options(self):
+        options = DEFAULT_OPTIONS.copy()
+        options.update(self.user_options)
+        options.update({
             'imageUpload': reverse('redactor_upload_image', kwargs={'upload_to': self.upload_to}),
             'fileUpload': reverse('redactor_upload_file', kwargs={'upload_to': self.upload_to})
+        return json.dumps(options)
     def render(self, name, value, attrs=None):
         html = super(RedactorEditor, self).render(name, value, attrs)
         final_attrs = self.build_attrs(attrs)
         id_ = final_attrs.get('id')
-        options = json.dumps(self.options)
-        html += INIT_JS % (id_, options)
+        html += INIT_JS % (id_, self.get_options())
         return mark_safe(html)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.