Tracking/Phone Home/Upgrade notification

pull/1315/merge
Dave Cranwell 2015-04-01 09:23:02 +01:00 zatwierdzone przez Karl Hobley
rodzic 589bc3e562
commit c18bab66c6
7 zmienionych plików z 86 dodań i 2 usunięć

Wyświetl plik

@ -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
-------------

Wyświetl plik

@ -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) {}
});
});

Wyświetl plik

@ -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);

Wyświetl plik

@ -86,5 +86,4 @@ header{
background-color:white;
}
}
}

Wyświetl plik

@ -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 %}

Wyświetl plik

@ -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>

Wyświetl plik

@ -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),
]