Automatic update checks (#434)

* Basic update checks

* Fix issues pointed out by @rixx

* First test

* Add tests

* Even more tests
This commit is contained in:
Raphael Michel
2017-04-01 15:34:34 +02:00
committed by GitHub
parent 867a8132aa
commit 4919f8991c
17 changed files with 625 additions and 12 deletions

View File

@@ -105,6 +105,13 @@
</li>
{% endfor %}
{% if warning_update_available %}
<li>
<a href="{% url 'control:global.update' %}" class="danger">
<i class="fa fa-bell"></i>
</a>
</li>
{% endif %}
<li>
<a href="{% url 'control:user.settings' %}">
<i class="fa fa-user"></i> {{ request.user.get_full_name }}
@@ -141,7 +148,8 @@
</li>
{% if request.user.is_superuser %}
<li>
<a href="{% url 'control:global-settings' %}" {% if "global-settings" in url_name %}class="active"{% endif %}>
<a href="{% url 'control:global.settings' %}"
{% if "global.settings" in url_name %}class="active"{% endif %}>
<i class="fa fa-wrench fa-fw"></i>
{% trans "Global settings" %}
</a>
@@ -173,6 +181,19 @@
</div>
{% endfor %}
{% endif %}
{% if warning_update_check_active %}
<div class="alert alert-info">
<a href="{% url "control:global.update" %}">
{% blocktrans trimmed %}
Starting with version 1.2.0, pretix automatically checks for updates in the background.
During this check, anonymous data is transmitted to servers operated by pretix'
developers. Click on this message to find out more, disable this feature or enter your
email address to get notified via email if a new update arrives. This message will
disappear once you clicked it.
{% endblocktrans %}
</a>
</div>
{% endif %}
{% if debug_warning %}
<div class="alert alert-danger">

View File

@@ -1,10 +1,8 @@
{% extends "pretixcontrol/base.html" %}
{% extends "pretixcontrol/global_settings_base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Global settings" %}{% endblock %}
{% block content %}
<h1>{% trans "Global settings" %}</h1>
{% block inner %}
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
{% bootstrap_form_errors form %}

View File

@@ -0,0 +1,22 @@
{% extends "pretixcontrol/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Global settings" %}{% endblock %}
{% block content %}
<h1>{% trans "Global settings" %}</h1>
<ul class="nav nav-pills">
<li {% if "global.settings" == url_name %}class="active"{% endif %}>
<a href="{% url 'control:global.settings' %}">
{% trans "General" %}
</a>
</li>
<li {% if "global.update" == url_name %}class="active"{% endif %}>
<a href="{% url 'control:global.update' %}">
{% trans "Update check" %}
</a>
</li>
</ul>
{% block inner %}
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,90 @@
{% extends "pretixcontrol/global_settings_base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block inner %}
<fieldset>
<legend>{% trans "Update check results" %}</legend>
{% if not gs.settings.update_check_perform %}
<div class="alert alert-warning">
{% trans "Update checks are disabled." %}
</div>
{% elif not gs.settings.update_check_last %}
<div class="alert alert-info">
{% trans "No update check has been performed yet since the last update of this installation. Update checks are performed on a daily basis if your cronjob is set up properly." %}
</div>
<form action="" method="post">
{% csrf_token %}
<p>
<button type="submit" name="trigger" value="1" class="btn btn-default">
{% trans "Check for updates now" %}
</button>
</p>
</form>
{% elif "error" in gs.settings.update_check_result %}
<div class="alert alert-danger">
{% trans "The last update check was not successful." %}
{% if gs.settings.update_check_result.error == "http_error" %}
{% trans "The pretix.eu server returned an error code." %}
{% elif gs.settings.update_check_result.error == "unavailable" %}
{% trans "The pretix.eu server could not be reached." %}
{% elif gs.settings.update_check_result.error == "development" %}
{% trans "This installation appears to be a development installation." %}
{% endif %}
</div>
<form action="" method="post">
{% csrf_token %}
<p>
<button type="submit" name="trigger" value="1" class="btn btn-default">
{% trans "Check for updates now" %}
</button>
</p>
</form>
{% else %}
<form action="" method="post">
{% csrf_token %}
<p>
{% blocktrans trimmed with date=gs.settings.update_check_last|date:"SHORT_DATETIME_FORMAT" %}
Last updated: {{ date }}
{% endblocktrans %}
<button type="submit" name="trigger" value="1" class="btn btn-default btn-xs">
{% trans "Check for updates now" %}
</button>
</p>
</form>
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "Component" %}</th>
<th>{% trans "Installed version" %}</th>
<th>{% trans "Latest version" %}</th>
</tr>
</thead>
<tbody>
{% for row in tbl %}
<tr class="{% if row.3 %}danger{% elif row.2 == "?" %}warning{% else %}success{% endif %}">
<td>{{ row.0 }}</td>
<td>{{ row.1 }}</td>
<td>{{ row.2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</fieldset>
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
<fieldset>
<legend>{% trans "Update check settings" %}</legend>
{% bootstrap_form_errors form %}
{% bootstrap_form form layout='horizontal' %}
</fieldset>
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}
</button>
</div>
</form>
{% endblock %}