{"id":1464,"date":"2017-02-01T10:31:27","date_gmt":"2017-02-01T18:31:27","guid":{"rendered":"http:\/\/www.laurenwood.org\/anyway\/?p=1464"},"modified":"2023-04-29T12:13:32","modified_gmt":"2023-04-29T19:13:32","slug":"submitting-news-on-xml-com","status":"publish","type":"post","link":"https:\/\/www.laurenwood.org\/anyway\/2017\/02\/submitting-news-on-xml-com\/","title":{"rendered":"Submitting news on <span class=\"caps\">XML<\/span>.com"},"content":{"rendered":"<p>I coded <a href=\"https:\/\/www.xml.com\"><span class=\"caps\">XML<\/span>.com<a> in <a href=\"https:\/\/wagtail.io\/\">Wag\u00adtail<\/a>, a <span class=\"caps\">CMS<\/span> based on <a href=\"https:\/\/www.djangoproject.com\/\">Django<\/a>. It works well for my needs and I like Python as a pro\u00adgram\u00adming lan\u00adguage. One of the big reas\u00adons I like Wag\u00adtail is that it includes a power\u00adful enough but not overly com\u00adplic\u00adated work\u00adflow with roles and a built-in mod\u00ader\u00ada\u00adtion and pre\u00adview system.<\/a><\/a><\/p>\n<p>But, I wanted a sys\u00adtem where people could sub\u00admit news items that would go into the mod\u00ader\u00ada\u00adtion queue without need\u00ading to sign up for a login first. For\u00adtu\u00adnately, Wag\u00adtail makes that pos\u00adsible, and there\u2019s a nice art\u00adicle by Erin Mul\u00adlaney at <a href=\"https:\/\/www.caktusgroup.com\/blog\/2016\/02\/15\/wagtail-2-steps-adding-pages-outside-cms\/\">Wag\u00adtail: 2 Steps for Adding Pages Out\u00adside of the <span class=\"caps\">CMS<\/span><\/a> that details all the steps you need. It all worked nicely in more recent ver\u00adsions of Wag\u00adtail (thanks, Erin!) except for one part, the noti\u00adfic\u00ada\u00adtion that the news item is in the mod\u00ader\u00ada\u00adtion queue. That was\u00adn\u2019t a stop-ship item, so <span class=\"caps\">XML<\/span>.com launched without those emails working.<\/p>\n<p>I\u2019ve now found the source of the prob\u00adlem. It turns out that when you sub\u00admit a news item in this way, it does\u00adn\u2019t have a login iden\u00adtity attached to it (obvi\u00adously, since there isn\u2019t one). The send_notification func\u00adtion that sends the email uses tem\u00adplates, and these tem\u00adplates use the login iden\u00adtity of the author in the body of the email. Since that does\u00adn\u2019t exist, the whole func\u00adtion&nbsp;fails.&nbsp;<\/p>\n<p>That means the solu\u00adtion is easy. The affected tem\u00adplates are <code>wagtailadmin\/notifications\/submitted.txt<\/code> and <code>wagtailadmin\/notifications\/submitted.html<\/code>, and Wag\u00adtail lets you <a href=\"https:\/\/docs.wagtail.org\/en\/latest\/advanced_topics\/customisation\/admin_templates.html\">cus\u00adtom\u00adize the admin tem\u00adplates<\/a>. I put my cus\u00adtom\u00adized admin tem\u00adplates into a utils applic\u00ada\u00adtion, which con\u00adtains all my util\u00adit\u00adies for the site. My <code>utils\/templates\/wagtailadmin\/notifications\/submitted.txt<\/code> file now has the content<\/p>\n<pre>\n{% extends 'wagtailadmin\/notifications\/submitted.txt' %}\n{% load i18n %}\n\n{% block content %}\n{% blocktrans with page=revision.page|safe %}The page \"{{ page }}\" has been submitted for moderation.{% endblocktrans %}\n\n{% trans \"You can preview the page here:\" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:preview_for_moderation' revision.id %}\n{% trans \"You can edit the page here:\" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' revision.page.id %}\n{% endblock %}\n<\/pre>\n<p>Sim\u00adil\u00adar changes are neces\u00adsary for the <code>wagtailadmin\/notifications\/submitted.html<\/code> file if you want to send <span class=\"caps\">HTML<\/span> emails instead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I coded <span class=\"caps\">XML<\/span>.com in Wag\u00adtail, a <span class=\"caps\">CMS<\/span> based on Django. It works well for my needs and I like Python as a pro\u00adgram\u00adming lan\u00adguage. One of the big reas\u00adons I like Wag\u00adtail is that it includes a power\u00adful enough but not overly com\u00adplic\u00adated work\u00adflow with roles and a built-in mod\u00ader\u00ada\u00adtion and pre\u00adview sys\u00adtem. But, I \u2026 <a href=\"https:\/\/www.laurenwood.org\/anyway\/2017\/02\/submitting-news-on-xml-com\/\" class=\"more-link\">Con\u00adtin\u00adue read\u00ading<span class=\"screen-reader-text\"> \u201cSub\u00admit\u00adting news on <span class=\"caps\">XML<\/span>.com\u201d<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":""},"categories":[112,6,114],"tags":[],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-django","category-technology","category-wagtail"],"_links":{"self":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/comments?post=1464"}],"version-history":[{"count":3,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1464\/revisions"}],"predecessor-version":[{"id":1556,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1464\/revisions\/1556"}],"wp:attachment":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/media?parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/categories?post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/tags?post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}