Fixed bug on backend failure error reporting

This commit is contained in:
Marc Aymerich 2016-03-18 10:13:25 +00:00
parent ec0c319ad4
commit 6a34ba8fd2
6 changed files with 33 additions and 23 deletions

View File

@ -430,11 +430,10 @@ mkhomedir_helper or create ssh homes with bash.rc and such
# 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
# upgrade to django 1.9 and make margins wider
# lets encrypt: DNS vs HTTP challange
# lets enctypt: autorenew
# lets encrypt: websites without / content
# Warning websites with ssl options without https protocol
# Schedule cancellation

View File

@ -202,10 +202,14 @@ class AccountAdminMixin(object):
except KeyError:
pass
else:
help_text = (
"Designates whether this account should be treated as active. "
"Unselect this instead of deleting accounts."
)
opts = self.model._meta
help_text = _(
"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:
help_text += "<br><b style='color:red;'>This user's account is dissabled</b>"
field.help_text = _(help_text)

View File

@ -95,14 +95,11 @@ class DomainAdmin(AccountAdminMixin, ExtendedModelAdmin):
return '<br>'.join(links)
add_url = reverse('admin:websites_website_add')
add_url += '?account=%i&domains=%i' % (domain.account_id, domain.pk)
context = {
'title': _("Add website"),
'url': add_url,
'image': '<img src="%s"></img>' % static('orchestra/images/add.png'),
}
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)
image = '<img src="%s"></img>' % static('orchestra/images/add.png')
add_link = '<a href="%s" title="%s">%s</a>' % (
add_url, _("Add website"), image
)
return _("No website %s") % (add_link)
display_websites.admin_order_field = 'websites__name'
display_websites.short_description = _("Websites")
display_websites.allow_tags = True

View File

@ -1,8 +1,9 @@
from django.contrib import messages, admin
from django.template.response import TemplateResponse
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 .helpers import is_valid_domain, read_live_lineages, configure_cert
@ -12,6 +13,18 @@ from .forms import LetsEncryptForm
def letsencrypt(modeladmin, request, queryset):
wildcards = 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')
for website in queryset:
for domain in website.domains.all():
@ -23,7 +36,7 @@ def letsencrypt(modeladmin, request, queryset):
action_value = 'letsencrypt'
if request.POST.get('post') == 'generic_confirmation':
form = LetsEncryptForm(domains, wildcards, request.POST)
if form.is_valid():
if not content_error and form.is_valid():
cleaned_data = form.cleaned_data
domains = set(cleaned_data['domains'])
operations = []
@ -86,10 +99,10 @@ def letsencrypt(modeladmin, request, queryset):
context = {
'title': _("Let's 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, "
"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,
'queryset': queryset,
'opts': opts,

View File

@ -45,10 +45,7 @@ class LetsEncryptController(ServiceController):
super().commit()
def get_context(self, website):
try:
content = website.content_set.get(path='/')
except website.content_set.model.DoesNotExist:
raise
return {
'letsencrypt_auto': settings.LETSENCRYPT_AUTO_PATH,
'webroot': content.webapp.get_path(),

View File

@ -128,7 +128,7 @@ def message_user(request, logs):
async)
if errors:
if total == 1:
msg = _('<a href="{url}">{name}</a> has fail to execute'),
msg = _('<a href="{url}">{name}</a> has fail to execute')
else:
msg = ungettext(
_('<a href="{url}">{errors} out of {total} backends</a> has fail to execute'),