One of those cases where I must be being a complete idiot (as usual) back story:
I have EmailGroup and EmailSub models, none of which inherit from any mezzanine models. EmailSub is a foriegnkey to EmailGroup. In the admin (EmailGroup's change_form) I've set up an admin action using django-object-actions <https://github.com/crccheck/django-object-actions> to send a bulk email to each EmailSub for the group. The bulk email button redirects to a confirmation page that also acts as a mini email writing box that I can set the subject, CC's, and attachments,* but most importantly a tinyMCE editor to edit the message.* Up until the tinyMCE part everything is fine, and i can send bulk email (using Mandrill/Mailchimp). I've tried two approaches but running out of steam and my head is starting to hurt: #1 try and ignore mezzanine's tinymce editor and use the default from www.tinymce.com using the tutorial <https://www.tinymce.com/docs/get-started/first-steps/>, on the confirmation page: This works great up until I try and implement file uploading. I've got as far as to bringing up the media library but there's javascript errors popping up and selecting an image/file to upload does nothing. My JS is ok but i just can't work out what's going on, Here is my JS to init tinyMCE, with the filebrowser code: function CustomFileBrowser(field_name, url, type, win) { var cmsURL = window.__filebrowser_url + '?pop=2' cmsURL = cmsURL + "&type=" + type; //console.log(tinyMCE.selectedInstance.editorId) tinyMCE.activeEditor.windowManager.open({ file: cmsURL, width: 820, // Your dimensions may differ - toy around with them! height: 500, resizable: "yes", scrollbars: "yes", inline: "no", // This parameter only has an effect if you use the inlinepopups plugin! close_previous: "no" }, { window: win, input: field_name, }); return false; } tinymce.init({ selector: '#mmessage', plugins: "image", image_advtab: true, file_browser_callback: CustomFileBrowser, relative_urls: false, }); My best guess is that tinyMCE.activeEditor.windowManager.open() is calling mezzanine's JS (tiny_mce_popup.js and FB_TinyMCE.js)...? Literally stumped with this. #2 Try and pass the form from the modelAdmin for EmailGroup: I'm struggling big time with this, here is my admin.py: from mezzanine.core.forms import TinyMceWidget class EmailForm(forms.Form): subject = forms.CharField() message = forms.CharField(widget=TinyMceWidget) class EmailGroupAdmin(DjangoObjectActions, admin.ModelAdmin): def email(self, request, queryset): form = EmailForm # will add form validation if request.POST.get('post'): if "cancel" in request.POST: pass else: subject = request.POST.get('subject', '') content = request.POST.get('message', '') ..sending mail function else: context = { 'title': _("Are you sure?"), 'email_group':queryset, 'form':form } return TemplateResponse(request, 'admin/my_cms/email/email_conf.html', context, current_app=self.admin_site.name) email.label = "Bulk Email" # optional email.short_description = "Send to subscribers" # optional objectactions = ('email', ) admin.site.register(EmailGroup, EmailGroupAdmin) I can't use a modelForm (i think) as the message content is not from any model,(will i only be able to do this with one?) I just can't get any assets loading at all, If i inspect the message textarea webpage i can see the class MceEditor has been appended but no css/js... I've also tried a slightly different approach here by trying to write the widget from scratch: class TinyMceWidget(forms.Textarea): """ This allows us to use our own TinyMCE setup script. """ class Media: css = { 'all': ('/static/filebrowser/css/filebrowser.css',) } js = ( "/static/grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js", "/static/filebrowser/js/FB_TinyMCE4.js", "%sjavascripts/app/tinymce_config.js" % settings.STATIC_URL, ) filebrowser/js/jquery-ui-1.9.1.custom.min.js filebrowser/js/filebrowser-popup.js def __init__(self, *args, **kwargs): super(TinyMceWidget, self).__init__(*args, **kwargs) self.attrs["class"] = "mceEditor" but i'm not exactly sure what assets need to be loaded.. and i get the same result, MceEditor class added but no assets Really sorry for the huge post.. google has been pretty rubbish with this, Any suggestions really appreciated -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
