letsencrypt: Add option to let Plinth "manage" certbot's renewal hooks

- add action commands for managing and running hooks

- adding template, view and url for managing and running hooks

- disable Plinth hook management on domain change
This commit is contained in:
Johannes Keyser authored and James Valleroy committed 2017-07-19 21:47:00 -04:00
1 parent 1d4289068a
commit 1069f84154
6 files changed
+334 -6

No files matched your search

@@ -49,7 +49,13 @@
<tbody>
{% for domain, domain_status in status.domains.items %}
<tr>
<td>{{ domain }}</td>
<td>
{% if domain == status.current_domain.name %}
<b>{{ domain }}</b>
{% else %}
{{ domain }}
{% endif %}
</td>
<td>
{% if domain_status.certificate_available and domain_status.validity == "valid" %}
<span class="label label-success">
@@ -128,6 +134,62 @@
</div>
</div>
<form class="form" method="post"
action="{% url 'letsencrypt:toggle_hooks' status.current_domain.name %}">
{% csrf_token %}
<div class="checkbox">
<label>
{% if status.current_domain.name and status.current_domain.has_cert %}
<input type="checkbox" name="toggle_hooks" id="id_toggle_hooks"
{% if status.current_domain.manage_hooks_enabled %}checked{% endif %}
onchange="this.form.submit();">
</input>
<noscript>
<button class="btn btn-sm btn-default" type="submit">
{% trans "Update config" %}</button>
</noscript>
{% else %}
<input type="checkbox" name="toggle_hooks" id="id_toggle_hooks"
class="disabled"></input>
<noscript>
<button class="btn btn-sm btn-default disabled" type="submit">
{% trans "Update config" %}</button>
</noscript>
{% endif %}
<span>
{% if status.current_domain.name %}
{% blocktrans with current_domain=status.current_domain.name %}
Let Plinth manage certificate renewal of
<b>{{ current_domain }}</b> (recommmended)
{% endblocktrans %}
{% else %}
{% blocktrans with current_domain=status.current_domain.name %}
Let Plinth manage certificate renewal of the current domain (recommmended)
{% endblocktrans %}
{% endif %}
</span>
</label>
</div>
<p class="help-block">
{% if status.current_domain.name and status.current_domain.has_cert %}
{% blocktrans trimmed %}
If {{ box_name }} manages the certificate renewal for the current domain,
it will ensure that all apps that use the certificate can use it, as soon
as it gets renewed.
{% endblocktrans %}
{% elif not status.current_domain.has_cert %}
{% blocktrans trimmed %}
<b>No certificate available for the current domain.</b>
First obtain a certificate to enable management of its renewal.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
<b>No current domain is configured.</b>
First configure a domain to enable management of its certificates.
{% endblocktrans %}
{% endif %}
</p>
</form>
{% include "diagnostics_button.html" with module="letsencrypt" enabled=True %}
{% else %}
{% blocktrans trimmed %}