def test_render_textareawithinlines_widget(self): neilmsg = ModelTest.objects.create( first_text="One small step for man", second_text="One giant leap for mankind") widget = TextareaWithInlines() self.assert_( InlinesDialogStr("id_test").widget_string() in conditional_escape(widget.render("test", neilmsg.second_text)))
def test_render_textareawithinlines_widget(self): neilmsg = ModelTest.objects.create( first_text="One small step for man", second_text="One giant leap for mankind") w = TextareaWithInlines() self.assertEqual( conditional_escape(w.render("test", neilmsg.second_text)), u'<textarea rows="10" cols="40" name="test" class="vLargeTextField">One giant leap for mankind</textarea><div style="margin-top:10px"><label>Inlines:</label><strong>Inline type:</strong> <select id="id_inline_content_type_for_test" onchange="document.getElementById(\'lookup_id_inline_for_test\').href = \'../../../\'+this.value+\'/\';" style="margin-right:20px;"><option>----------</option><option value="inline_media/picture">Inline_media: Picture</option><option value="inline_media/pictureset">Inline_media: Pictureset</option></select><strong>Object:</strong> <input type="text" class="vIntegerField" id="id_inline_for_test" size="10" /> <a id="lookup_id_inline_for_test" href="#" class="related-lookup" onclick="if(document.getElementById(\'id_inline_content_type_for_test\').value != \'----------\') { return showRelatedObjectLookupPopup(this); }" style="margin-right:20px;"><img src="/media/img/admin/selector-search.gif" width="16" height="16" alt="Loopup" /></a> <strong>Class:</strong> <select id="id_inline_class_for_test"><option value="inline_small_left">Small left</option><option value="inline_small_right">Small right</option><option value="inline_medium_left">Medium left</option><option value="inline_medium_right">Medium right</option><option value="inline_large_left">Large left</option><option value="inline_large_right">Large right</option><option value="inline_full">Full centered</option></select><input type="button" value="Add" style="margin-left:10px;" onclick="return insertInline(document.getElementById(\'id_inline_content_type_for_test\').value, document.getElementById(\'id_inline_for_test\').value, document.getElementById(\'id_inline_class_for_test\').value, \'test\')" /><p class="help">Insert inlines into your body by choosing an inline type, then an object, then a class.</p></div>')
def test_render_textareawithinlines_widget(self): neilmsg = ModelTest.objects.create( first_text="One small step for man", second_text="One giant leap for mankind") widget = TextareaWithInlines() self.assert_( InlinesDialogStr("id_test").widget_string() in conditional_escape( widget.render("test", neilmsg.second_text)))
def test_render_textareawithinlines_widget(self): neilmsg = ModelTest.objects.create( first_text="One small step for man", second_text="One giant leap for mankind") w = TextareaWithInlines() self.assertEqual( conditional_escape(w.render("test", neilmsg.second_text)), u'<textarea rows="10" cols="40" name="test" class="vLargeTextField">One giant leap for mankind</textarea><div style="margin-top:10px"><label>Inlines:</label><strong>Inline type:</strong> <select id="id_inline_content_type_for_test" onchange="document.getElementById(\'lookup_id_inline_for_test\').href = \'../../../\'+this.value+\'/\';" style="margin-right:20px;"><option>----------</option><option value="inline_media/picture">Inline_media: Picture</option><option value="inline_media/pictureset">Inline_media: Pictureset</option></select><strong>Object:</strong> <input type="text" class="vIntegerField" id="id_inline_for_test" size="10" /> <a id="lookup_id_inline_for_test" href="#" class="related-lookup" onclick="if(document.getElementById(\'id_inline_content_type_for_test\').value != \'----------\') { return showRelatedObjectLookupPopup(this); }" style="margin-right:20px;"><img src="/media/img/admin/selector-search.gif" width="16" height="16" alt="Loopup" /></a> <strong>Class:</strong> <select id="id_inline_class_for_test"><option value="inline_small_left">Small left</option><option value="inline_small_right">Small right</option><option value="inline_medium_left">Medium left</option><option value="inline_medium_right">Medium right</option><option value="inline_large_left">Large left</option><option value="inline_large_right">Large right</option><option value="inline_full">Full centered</option></select><input type="button" value="Add" style="margin-left:10px;" onclick="return insertInline(document.getElementById(\'id_inline_content_type_for_test\').value, document.getElementById(\'id_inline_for_test\').value, document.getElementById(\'id_inline_class_for_test\').value, \'test\')" /><p class="help">Insert inlines into your body by choosing an inline type, then an object, then a class.</p></div>' )
def test_render_textareawithinlines_widget(self): neilmsg = ModelTest.objects.create( first_text="One small step for man", second_text="One giant leap for mankind") widget = TextareaWithInlines() manually_rendered = u'<textarea rows="10" cols="40" name="test" class="vLargeTextField">One giant leap for mankind</textarea><div style="margin-top:10px"><label>Inlines:</label>' manually_rendered += InlinesDialogStr("id_test").widget_string() manually_rendered += u'<p class="help">Insert inlines into your body by choosing an inline type, then an object, then a class.</p></div>' self.assertEqual(conditional_escape(widget.render("test", neilmsg.second_text)), manually_rendered)
def formfield(self, **kwargs): # attrs = get_attrs(self.model, self.formfield.im_self.name) attrs = get_attrs(self.model, self.name) if attrs: widget = TextareaWithInlines(attrs=attrs) else: widget = TextareaWithInlines defaults = {"widget": widget} kwargs.update(defaults) return super(TextFieldWithInlines, self).formfield(**kwargs)