Fixed bug on backend failure error reporting
This commit is contained in:
parent
ec0c319ad4
commit
6a34ba8fd2
3
TODO.md
3
TODO.md
|
@ -430,11 +430,10 @@ mkhomedir_helper or create ssh homes with bash.rc and such
|
||||||
# Automatically re-run backends until success? only timedout executions?
|
# Automatically re-run backends until success? only timedout executions?
|
||||||
# TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects
|
# TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects
|
||||||
|
|
||||||
|
|
||||||
# upgrade to django 1.9 and make margins wider
|
# upgrade to django 1.9 and make margins wider
|
||||||
# lets encrypt: DNS vs HTTP challange
|
# lets encrypt: DNS vs HTTP challange
|
||||||
# lets enctypt: autorenew
|
# lets enctypt: autorenew
|
||||||
# lets encrypt: websites without / content
|
|
||||||
|
|
||||||
# Warning websites with ssl options without https protocol
|
# Warning websites with ssl options without https protocol
|
||||||
|
|
||||||
|
# Schedule cancellation
|
||||||
|
|
|
@ -202,10 +202,14 @@ class AccountAdminMixin(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
help_text = (
|
opts = self.model._meta
|
||||||
"Designates whether this account should be treated as active. "
|
help_text = _(
|
||||||
"Unselect this instead of deleting accounts."
|
"Designates whether this %(name)s should be treated as active. "
|
||||||
)
|
"Unselect this instead of deleting %(plural_name)s."
|
||||||
|
) % {
|
||||||
|
'name': opts.verbose_name,
|
||||||
|
'plural_name': opts.verbose_name_plural,
|
||||||
|
}
|
||||||
if obj and not obj.account.is_active:
|
if obj and not obj.account.is_active:
|
||||||
help_text += "<br><b style='color:red;'>This user's account is dissabled</b>"
|
help_text += "<br><b style='color:red;'>This user's account is dissabled</b>"
|
||||||
field.help_text = _(help_text)
|
field.help_text = _(help_text)
|
||||||
|
|
|
@ -95,14 +95,11 @@ class DomainAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
||||||
return '<br>'.join(links)
|
return '<br>'.join(links)
|
||||||
add_url = reverse('admin:websites_website_add')
|
add_url = reverse('admin:websites_website_add')
|
||||||
add_url += '?account=%i&domains=%i' % (domain.account_id, domain.pk)
|
add_url += '?account=%i&domains=%i' % (domain.account_id, domain.pk)
|
||||||
context = {
|
image = '<img src="%s"></img>' % static('orchestra/images/add.png')
|
||||||
'title': _("Add website"),
|
add_link = '<a href="%s" title="%s">%s</a>' % (
|
||||||
'url': add_url,
|
add_url, _("Add website"), image
|
||||||
'image': '<img src="%s"></img>' % static('orchestra/images/add.png'),
|
)
|
||||||
}
|
return _("No website %s") % (add_link)
|
||||||
add_link = '<a href="%(url)s" title="%(title)s">%(image)s</a>' % context
|
|
||||||
site_link = get_on_site_link('http://%s' % domain.name)
|
|
||||||
return _("No website %s %s") % (add_link, site_link)
|
|
||||||
display_websites.admin_order_field = 'websites__name'
|
display_websites.admin_order_field = 'websites__name'
|
||||||
display_websites.short_description = _("Websites")
|
display_websites.short_description = _("Websites")
|
||||||
display_websites.allow_tags = True
|
display_websites.allow_tags = True
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from django.contrib import messages, admin
|
from django.contrib import messages, admin
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import ungettext, ugettext_lazy as _
|
from django.utils.translation import ungettext, ugettext, ugettext_lazy as _
|
||||||
|
|
||||||
|
from orchestra.admin.utils import admin_link
|
||||||
from orchestra.contrib.orchestration import Operation, helpers
|
from orchestra.contrib.orchestration import Operation, helpers
|
||||||
|
|
||||||
from .helpers import is_valid_domain, read_live_lineages, configure_cert
|
from .helpers import is_valid_domain, read_live_lineages, configure_cert
|
||||||
|
@ -12,6 +13,18 @@ from .forms import LetsEncryptForm
|
||||||
def letsencrypt(modeladmin, request, queryset):
|
def letsencrypt(modeladmin, request, queryset):
|
||||||
wildcards = set()
|
wildcards = set()
|
||||||
domains = set()
|
domains = set()
|
||||||
|
content_error = ''
|
||||||
|
contentless = queryset.exclude(content__path='/').distinct()
|
||||||
|
if contentless:
|
||||||
|
content_error = ungettext(
|
||||||
|
ugettext("Selected website %s doesn't have a webapp mounted on <tt>/</tt>."),
|
||||||
|
ugettext("Selected websites %s don't have a webapp mounted on <tt>/</tt>."),
|
||||||
|
len(contentless),
|
||||||
|
)
|
||||||
|
content_error += ugettext("<br>Websites need a webapp (e.g. static) mounted on </tt>/</tt> "
|
||||||
|
"for let's encrypt HTTP-01 challenge to work.")
|
||||||
|
content_error = content_error % ', '.join((admin_link()(website) for website in contentless))
|
||||||
|
content_error = '<ul class="errorlist"><li>%s</li></ul>' % content_error
|
||||||
queryset = queryset.prefetch_related('domains')
|
queryset = queryset.prefetch_related('domains')
|
||||||
for website in queryset:
|
for website in queryset:
|
||||||
for domain in website.domains.all():
|
for domain in website.domains.all():
|
||||||
|
@ -23,7 +36,7 @@ def letsencrypt(modeladmin, request, queryset):
|
||||||
action_value = 'letsencrypt'
|
action_value = 'letsencrypt'
|
||||||
if request.POST.get('post') == 'generic_confirmation':
|
if request.POST.get('post') == 'generic_confirmation':
|
||||||
form = LetsEncryptForm(domains, wildcards, request.POST)
|
form = LetsEncryptForm(domains, wildcards, request.POST)
|
||||||
if form.is_valid():
|
if not content_error and form.is_valid():
|
||||||
cleaned_data = form.cleaned_data
|
cleaned_data = form.cleaned_data
|
||||||
domains = set(cleaned_data['domains'])
|
domains = set(cleaned_data['domains'])
|
||||||
operations = []
|
operations = []
|
||||||
|
@ -86,10 +99,10 @@ def letsencrypt(modeladmin, request, queryset):
|
||||||
context = {
|
context = {
|
||||||
'title': _("Let's encrypt!"),
|
'title': _("Let's encrypt!"),
|
||||||
'action_name': _("Encrypt"),
|
'action_name': _("Encrypt"),
|
||||||
'content_message': _("You are going to request certificates for the following domains.<br>"
|
'content_message': ugettext("You are going to request certificates for the following domains.<br>"
|
||||||
"This operation is safe to run multiple times, "
|
"This operation is safe to run multiple times, "
|
||||||
"existing certificates will not be regenerated. "
|
"existing certificates will not be regenerated. "
|
||||||
"Also notice that let's encrypt does not currently support wildcard certificates."),
|
"Also notice that let's encrypt does not currently support wildcard certificates.") + content_error,
|
||||||
'action_value': action_value,
|
'action_value': action_value,
|
||||||
'queryset': queryset,
|
'queryset': queryset,
|
||||||
'opts': opts,
|
'opts': opts,
|
||||||
|
|
|
@ -45,10 +45,7 @@ class LetsEncryptController(ServiceController):
|
||||||
super().commit()
|
super().commit()
|
||||||
|
|
||||||
def get_context(self, website):
|
def get_context(self, website):
|
||||||
try:
|
content = website.content_set.get(path='/')
|
||||||
content = website.content_set.get(path='/')
|
|
||||||
except website.content_set.model.DoesNotExist:
|
|
||||||
raise
|
|
||||||
return {
|
return {
|
||||||
'letsencrypt_auto': settings.LETSENCRYPT_AUTO_PATH,
|
'letsencrypt_auto': settings.LETSENCRYPT_AUTO_PATH,
|
||||||
'webroot': content.webapp.get_path(),
|
'webroot': content.webapp.get_path(),
|
||||||
|
|
|
@ -128,7 +128,7 @@ def message_user(request, logs):
|
||||||
async)
|
async)
|
||||||
if errors:
|
if errors:
|
||||||
if total == 1:
|
if total == 1:
|
||||||
msg = _('<a href="{url}">{name}</a> has fail to execute'),
|
msg = _('<a href="{url}">{name}</a> has fail to execute')
|
||||||
else:
|
else:
|
||||||
msg = ungettext(
|
msg = ungettext(
|
||||||
_('<a href="{url}">{errors} out of {total} backends</a> has fail to execute'),
|
_('<a href="{url}">{errors} out of {total} backends</a> has fail to execute'),
|
||||||
|
|
Loading…
Reference in New Issue