This commit is contained in:
Antoine Nguyen
2016-11-25 17:48:17 +01:00
parent 3f4551b7f3
commit 31fa537f02
6 changed files with 35 additions and 36 deletions
-1
View File
@@ -16,7 +16,6 @@ extra_domain_dashboard_widgets = django.dispatch.Signal(
providing_args=["user", "domain"])
extra_domain_filters = django.dispatch.Signal()
extra_domain_forms = django.dispatch.Signal(providing_args=["user", "domain"])
extra_domain_import_help = django.dispatch.Signal()
extra_domain_menu_entries = django.dispatch.Signal(providing_args=["user"])
extra_domain_qset_filters = django.dispatch.Signal(
providing_args=["domfilter", "extrafilters"])
@@ -0,0 +1,16 @@
{% extends "admin/importform.html" %}
{% load i18n %}
{% block helptext %}
{% blocktrans trimmed %}
Provide a CSV file where lines respect one of the following formats:
<ul>
<li><em>domain; name; quota; enabled</em></li>
<li><em>domainalias; name; targeted domain; enabled</em></li>
<li><em>relaydomain; name; target host; service; enabled; verify recipients</em></li>
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>
<p>You can use a different character as separator.</p>
{% endblocktrans %}
{% endblock %}
@@ -0,0 +1,15 @@
{% extends "admin/importform.html" %}
{% load i18n %}
{% block helptext %}
{% blocktrans trimmed %}
Provide a CSV file where lines respect one of the following formats:
<ul>
<li><em>account; loginname; password; first name; last name; enabled; group; address; quota; [, domain, ...]</em></li>
<li><em>alias; address; enabled; recipient; recipient; ...</em></li>
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>
<p>You can use a different character as separator.</p>
{% endblocktrans %}
{% endblock %}
@@ -4,7 +4,7 @@
{% block formbody %}
<div class="alert alert-info">
<h4>{% trans "Help" %}</h4>
{{ helptext|safe }}
{% block helptext %}{% endblock %}
</div>
{% render_form form %}
<iframe id="import_target" name="import_target" src="#"
+3 -26
View File
@@ -82,18 +82,6 @@ def import_domains(request):
if request.method == "POST":
return importdata(request)
results = signals.extra_domain_import_help.send(sender="import_domains")
extra_help = reduce(lambda a, b: a + b, [result[1] for result in results])
helptext = _("""Provide a CSV file where lines respect one of the following formats:
<ul>
<li><em>domain; name; quota; enabled</em></li>
<li><em>domainalias; name; targeted domain; enabled</em></li>
%s
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>
<p>You can use a different character as separator.</p>
""") % "".join(extra_help)
ctx = dict(
title=_("Import domains"),
action_label=_("Import"),
@@ -102,10 +90,9 @@ def import_domains(request):
formid="importform",
enctype="multipart/form-data",
target="import_target",
helptext=helptext,
form=ImportDataForm()
)
return render(request, "admin/importform.html", ctx)
return render(request, "admin/import_domains_form.html", ctx)
@login_required
@@ -117,15 +104,6 @@ def import_identities(request):
if request.method == "POST":
return importdata(request, ImportIdentitiesForm)
helptext = _("""Provide a CSV file where lines respect one of the following formats:
<ul>
<li><em>account; loginname; password; first name; last name; enabled; group; address; quota; [, domain, ...]</em></li>
<li><em>alias; address; enabled; recipient; recipient; ...</em></li>
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>
<p>You can use a different character as separator.</p>
""")
ctx = dict(
title=_("Import identities"),
action_label=_("Import"),
@@ -134,7 +112,6 @@ def import_identities(request):
formid="importform",
enctype="multipart/form-data",
target="import_target",
form=ImportIdentitiesForm(),
helptext=helptext
form=ImportIdentitiesForm()
)
return render(request, "admin/importform.html", ctx)
return render(request, "admin/import_identities_form.html", ctx)
-8
View File
@@ -116,14 +116,6 @@ def fill_domain_instances(sender, user, domain, **kwargs):
return {"relaydomain": domain.relaydomain}
@receiver(admin_signals.extra_domain_import_help)
def extra_domain_import_help(sender, **kwargs):
"""Add extra help lines."""
return [_("""
<li><em>relaydomain; name; target host; service; enabled; verify recipients</em></li>
""")]
@receiver(admin_signals.extra_domain_qset_filters)
def extra_domain_entries(sender, domfilter, extrafilters, **kwargs):
"""Return extra queryset filters."""