* New "import data" feature (only supports mailboxes for now)

* Some javascript cleanup into the admin. application

see #191
This commit is contained in:
Antoine Nguyen
2011-12-09 14:38:56 +01:00
parent 767343640a
commit 4fcc5b7911
14 changed files with 226 additions and 86 deletions
+2 -1
View File
@@ -5,7 +5,8 @@
{% block content %}
<div class="title"><h1>{{ title }}</h1></div>
{% if error %}<div class="error">{{ error }}</div>{% endif %}
<form action="{{ action }}" method="POST" id="{{ formid }}" name="{{ formid }}">
<form action="{{ action }}" enctype="{{ enctype }}"
method="POST" id="{{ formid }}" name="{{ formid }}">
{% include "common/genericform.html" %}
{% block extrafields %}{% endblock %}
<div class="spacer"></div>
+2 -41
View File
@@ -1,50 +1,11 @@
{% extends "nlayout.html" %}
{% load i18n admin_extras libextras %}
{% block html_head %}
<script src="{{ MEDIA_URL }}js/domains.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/confirmation.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/domains.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEvent("domready", function() {
var rooturl = "{% url index %}";
$$("a[name=new]").addEvent("click", function(evt) {
var type = $("objects").get("name");
var sizes = $("objects").get("rel").split(" ");
evt.stop();
SqueezeBox.open(rooturl + type + "/new/", {
size: {x: parseInt(sizes[0]), y: parseInt(sizes[1])},
handler: 'iframe'
});
});
$$("a[name=remove]").addEvent("click", function(evt) {
evt.stop();
if (objtable._selectedRows.length == 0) {
return;
}
var type = $("objects").get("name");
var selection = "";
objtable._selectedRows.each(function(item) {
var options = JSON.decode(item.get("rel"));
if ($defined(options) && $defined(options.ui_disabled) && options.ui_disabled == "True") {
return;
}
if (selection != "") {
selection += ",";
}
selection += item.get("id");
});
if (selection == "") {
return;
}
new Confirmation(rooturl + type + "/delete/", "selection=" + selection,
"{% trans 'Remove this selection?' %}", {
{% if deloptions %}checkboxes: { {% join deloptions %} }{% endif %}
});
});
new Domains("{% url index %}"{% if deloptions %}, { {% join deloptions %} } {% endif %});
});
</script>
{% endblock %}
+65
View File
@@ -0,0 +1,65 @@
{% extends "layout_simple.html" %}
{% load i18n %}
{% block html_head %}
{{ block.super }}
<style>
#id_sepcar {
width: 10px;
}
#import_result, #import_status {
width: 100%;
text-align: center;
}
#import_result {
color: green;
font-weight: bold;
}
</style>
<script type="text/javascript">
function import_cb(status, msg) {
$("import_status").setStyle("display", "none");
$("submit").set("disabled", false);
if (status == "ok") {
parent.location.reload();
parent.SqueezeBox.close();
} else {
$("import_result").set("html", "");
$("error").set("html", msg);
}
}
window.addEvent("domready", function() {
$("importform").addEvent("submit", function(evt) {
if ($("id_sourcefile").value == "") {
evt.stop();
return;
}
$("import_status").setStyle("display", "block");
$("submit").set("disabled", true);
});
});
</script>
{% endblock %}
{% block content %}
<div class="title"><h1>{% trans "Import data" %}</h1></div>
<div id="error" class="error">{{ error }}</div>
<form action="{% url admin.views.importdata %}" enctype="multipart/form-data"
target="import_target"
method="POST" id="importform" name="importform">
{% include "common/genericform.html" %}
<div class="spacer"></div>
<div class="lastrow" align="center">
<input type="submit" id="submit" name="submit" value="{% trans 'Import' %}" />
</div>
</form>
<iframe id="import_target" name="import_target" src="#"
style="width:0;height:0;border:0px solid #fff;"></iframe>
<div id="import_status" style="display:none">
<img src="{{MEDIA_URL}}css/spinner.gif" /> {% trans "Importing..." %}
</div>
<div id="import_result"></div>
{% endblock %}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
parent.import_cb("{{ status }}", "{{ msg }}");
</script>
</head>
<body></body>
</html>