Generate a unique id for each textarea
Pass these to TinyMCE so that comments also have a TinyMCE editor.
Fixes issue 1380
diff --git a/app/soc/modules/gci/views/task.py b/app/soc/modules/gci/views/task.py
index 4cd8515..c96ac41 100644
--- a/app/soc/modules/gci/views/task.py
+++ b/app/soc/modules/gci/views/task.py
@@ -78,6 +78,15 @@
css_prefix = 'gci_comment'
fields = ['title', 'content']
+ def idSuffix(self, field):
+ if field.name != 'content':
+ return ''
+
+ if not self.reply:
+ return ''
+
+ return "-%d" % self.reply
+
def __init__(self, reply, *args, **kwargs):
super(CommentForm, self).__init__(*args, **kwargs)
self.reply = reply
@@ -244,6 +253,7 @@
if self.data.is_visible:
context['work_submissions'] = WorkSubmissions(self.data)
+ context['comment_ids'] = [i.key().id() for i in self.data.comments]
context['comments'] = CommentsTemplate(self.data)
if not context['is_mentor']:
diff --git a/app/soc/templates/v2/modules/gci/task/public.html b/app/soc/templates/v2/modules/gci/task/public.html
index 383578e..380475d 100644
--- a/app/soc/templates/v2/modules/gci/task/public.html
+++ b/app/soc/templates/v2/modules/gci/task/public.html
@@ -38,7 +38,10 @@
null,
function () {
{% if comments %}
- tinyMCE.init(melange.tinyMceConfig(["melange-content-textarea"]));
+ fields = ["melange-content-textarea"
+{% for id in comment_ids %},"melange-content-textarea-{{ id }}"{% endfor %}
+ ];
+ tinyMCE.init(melange.tinyMceConfig(fields));
{% endif %}
<!-- Task pages: Hide/show reply box -->
jQuery(document).ready(function(){