kopia lustrzana https://github.com/wagtail/wagtail
Tracking/Phone Home/Upgrade notification
rodzic
589bc3e562
commit
c18bab66c6
|
@ -217,6 +217,16 @@ Email Notifications
|
|||
Wagtail sends email notifications when content is submitted for moderation, and when the content is accepted or rejected. This setting lets you pick which email address these automatic notifications will come from. If omitted, Django will fall back to using the ``DEFAULT_FROM_EMAIL`` variable if set, and ``webmaster@localhost`` if not.
|
||||
|
||||
|
||||
Wagtail update notifications
|
||||
----------------------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
WAGTAIL_ENABLE_UPDATE_CHECK = True
|
||||
|
||||
For admins only, Wagtail performs a check on the dashboard to see if newer releases are available. This also provides the Wagtail team with extremely basic information about where Wagtail is in use. If you'd rather not receive update notifications, or if you'd like your site to remain unknown, you can disable it with this setting.
|
||||
|
||||
|
||||
Private Pages
|
||||
-------------
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
$(function() {
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* Expected JSON payload:
|
||||
* {
|
||||
* "version" : "1.2.3", // Version number. Can only contain numbers and decimal point.
|
||||
* "url" : "https://wagtail.io" // Absolute URL to page/file containing release notes or actual package. It's up to you.
|
||||
* }
|
||||
*/
|
||||
|
||||
function cmpVersion(a, b) {
|
||||
var i;
|
||||
var cmp;
|
||||
var len;
|
||||
var re = /(\.0)+[^\.]*$/;
|
||||
|
||||
a = (a + '').replace(re, '').split('.');
|
||||
b = (b + '').replace(re, '').split('.');
|
||||
len = Math.min(a.length, b.length);
|
||||
for (i = 0; i < len; i++) {
|
||||
cmp = parseInt(a[i], 10) - parseInt(b[i], 10);
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
|
||||
return a.length - b.length;
|
||||
}
|
||||
|
||||
function gtVersion(a, b) {
|
||||
return cmpVersion(a, b) > 0;
|
||||
}
|
||||
|
||||
var releasesUrl = 'https://releases.wagtail.io/latest.txt';
|
||||
var currentVersion = window.wagtailVersion;
|
||||
|
||||
$.getJSON(releasesUrl, function(data) {
|
||||
try {
|
||||
if (data.version && gtVersion(data.version, currentVersion)) {
|
||||
var $container = $('.panel-upgrade-notification')
|
||||
$('.newversion', $container).html(data.version);
|
||||
$('.releasenotes-link', $container).attr('href', data.url);
|
||||
$container.show();
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
});
|
|
@ -80,6 +80,7 @@ dd{
|
|||
padding:1em;
|
||||
margin:1em 0;
|
||||
clear:both;
|
||||
color:$color-text-base;
|
||||
|
||||
p{
|
||||
margin-top:0;
|
||||
|
@ -88,6 +89,9 @@ dd{
|
|||
margin-bottom:0;
|
||||
}
|
||||
}
|
||||
a{
|
||||
color:$color-teal;
|
||||
}
|
||||
}
|
||||
.help-info, .help-warning, .help-critical{
|
||||
@include border-radius(3px);
|
||||
|
|
|
@ -86,5 +86,4 @@ header{
|
|||
background-color:white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,5 +31,4 @@
|
|||
{% else %}
|
||||
<p>{% trans "This is your dashboard on which helpful information about content you've created will be displayed." %}</p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{% load wagtailcore_tags static %}
|
||||
|
||||
<div class="panel nice-padding panel-upgrade-notification" style="display:none">
|
||||
<div class="help-block help-warning">Wagtail upgrade available. Your version: <strong>{% wagtail_version %}</strong>. New version: <strong class="newversion"></strong>. <a class="releasenotes-link" href="">Read the release notes.</a></div>
|
||||
|
||||
<script>window.wagtailVersion = "{% wagtail_version %}";</script>
|
||||
<script src="{% static 'wagtailadmin/js/upgrade_notify.js' %}" async="true"></script>
|
||||
</div>
|
|
@ -9,6 +9,21 @@ from wagtail.wagtailadmin.site_summary import SiteSummaryPanel
|
|||
|
||||
|
||||
# Panels for the homepage
|
||||
|
||||
class UpgradeNotificationPanel(object):
|
||||
name = 'upgrade_notification'
|
||||
order = 100
|
||||
|
||||
def __init__(self, request):
|
||||
self.request = request
|
||||
|
||||
def render(self):
|
||||
if self.request.user.is_superuser and getattr(settings, "WAGTAIL_ENABLE_UPDATE_CHECK", True):
|
||||
return render_to_string('wagtailadmin/home/upgrade_notification.html', {}, request=self.request)
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
class PagesForModerationPanel(object):
|
||||
name = 'pages_for_moderation'
|
||||
order = 200
|
||||
|
@ -49,6 +64,7 @@ def home(request):
|
|||
|
||||
panels = [
|
||||
SiteSummaryPanel(request),
|
||||
UpgradeNotificationPanel(request),
|
||||
PagesForModerationPanel(request),
|
||||
RecentEditsPanel(request),
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue