mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
@@ -0,0 +1,49 @@
|
||||
var Settings = function(options) {
|
||||
this.initialize(options);
|
||||
};
|
||||
|
||||
Settings.prototype = {
|
||||
constructor: Settings,
|
||||
|
||||
defaults: {
|
||||
deflocation: "parameters/"
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.options = $.extend({}, this.defaults, options);
|
||||
this.options.defcallback = $.proxy(this.default_cb, this);
|
||||
this.navobj = new History(this.options);
|
||||
|
||||
this.listen();
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
$("a.ajaxlink").click($.proxy(this.load_page, this));
|
||||
$(document).on("click", "#update", $.proxy(function(e) {
|
||||
simple_ajax_form_post(e, {
|
||||
formid: "settings_form",
|
||||
reload_on_success: false,
|
||||
success_cb: $.proxy(this.save_cb, this)
|
||||
});
|
||||
}, this));
|
||||
},
|
||||
|
||||
save_cb: function(data) {
|
||||
if (this.navobj.getbaseurl() == 'extensions') {
|
||||
window.location.reload();
|
||||
}
|
||||
$("body").notify("success", data.respmsg, 2000);
|
||||
},
|
||||
|
||||
load_page: function(e) {
|
||||
var $link = get_target(e);
|
||||
e.preventDefault();
|
||||
this.navobj.baseurl($link.attr("href")).update();
|
||||
},
|
||||
|
||||
default_cb: function(data) {
|
||||
$("a.ajaxlink").parent().removeClass("active");
|
||||
$("a[name=" + this.navobj.getbaseurl() + "]").parent().addClass("active");
|
||||
$("#settings_content").html(data.content);
|
||||
}
|
||||
};
|
||||
@@ -1,8 +1,6 @@
|
||||
{% extends "admin/settings_header.html" %}{% load i18n %}
|
||||
{% block pagetitle %}{% trans "Extensions" %}{% endblock %}
|
||||
{% block apparea %}
|
||||
<form method="POST" action="{% url modoboa.admin.views.saveextensions %}">
|
||||
{% load i18n %}
|
||||
<h2>{% trans "Extensions" %} <small>{% trans "Choose the extension(s) to use" %}</small></h2><hr />
|
||||
<form id="settings_form" method="POST" action="{% url modoboa.admin.views.saveextensions %}">
|
||||
{{ extensions|safe }}
|
||||
</form>
|
||||
<a href="#" class="btn btn-primary" id="update" name="update">{% trans 'Save' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
{% extends "admin/settings_header.html" %}{% load i18n %}
|
||||
{% block pagetitle %}{% trans "Parameters" %}{% endblock %}
|
||||
{% block apparea %}
|
||||
{% load i18n %}
|
||||
{% url modoboa.admin.views.saveparameters as action %}
|
||||
<form method="POST" action="{{ action }}" id="params_form" class="form-horizontal">
|
||||
<h2>{% trans "Parameters" %} <small>{% trans "Configure Modoboa" %}</small></h2><hr />
|
||||
<form id="settings_form" method="POST" action="{{ action }}" class="form-horizontal">
|
||||
{% include "common/parameters.html" %}
|
||||
</form>
|
||||
<hr>
|
||||
<a href="#" class="btn btn-primary" id="update" name="update">{% trans 'Save' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
{% extends "twocols.html" %}
|
||||
{% load i18n libextras admin_extras %}
|
||||
{% block pagetitle %}{% trans "Modoboa settings" %}{% endblock %}
|
||||
{% block html_head %}
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/history.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/settings.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#update").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
var $form = $("form");
|
||||
|
||||
$.post($form.attr("action"), $form.serialize(), function(data) {
|
||||
if (data.status == "ok") {
|
||||
if (data.reload) {
|
||||
window.location.reload();
|
||||
}
|
||||
$("body").notify("success", data.message, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
var settings = new Settings({});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block leftcol %}<div class="well sidebar-nav">{% settings_menu left_selection user %}</div>{% endblock %}
|
||||
{% block apparea %}<div id="settings_content"></div>{% endblock %}
|
||||
|
||||
@@ -33,7 +33,7 @@ def admin_menu(selection, user):
|
||||
entries += [
|
||||
{"name" : "settings",
|
||||
"label" : _("Modoboa"),
|
||||
"url" : reverse(admin.views.viewparameters)}
|
||||
"url" : reverse(admin.views.viewsettings)}
|
||||
]
|
||||
|
||||
if not len(entries):
|
||||
@@ -45,12 +45,14 @@ def admin_menu(selection, user):
|
||||
def settings_menu(selection, user):
|
||||
entries = [
|
||||
{"name" : "extensions",
|
||||
"url" : reverse(admin.views.viewextensions),
|
||||
"class" : "ajaxlink",
|
||||
"url" : "extensions/",
|
||||
"label" : _("Extensions"),
|
||||
"img" : static_url("pics/extensions.png")},
|
||||
"img" : ""},
|
||||
{"name" : "parameters",
|
||||
"url" : reverse(admin.views.viewparameters),
|
||||
"img" : static_url("pics/domains.png"),
|
||||
"class" : "ajaxlink",
|
||||
"url" : "parameters/",
|
||||
"img" : "",
|
||||
"label" : _("Parameters")},
|
||||
]
|
||||
return render_to_string('common/menu.html', {
|
||||
|
||||
@@ -11,7 +11,7 @@ urlpatterns = patterns(
|
||||
(r'^domains/delete/$', 'deldomain'),
|
||||
(r'^domains/import/$', 'import_domains'),
|
||||
|
||||
(r'^settings/$', 'viewparameters'),
|
||||
(r'^settings/$', 'viewsettings'),
|
||||
(r'^settings/parameters/$', 'viewparameters'),
|
||||
(r'^settings/parameters/save/$', 'saveparameters'),
|
||||
(r'^settings/extensions/$', 'viewextensions'),
|
||||
|
||||
+15
-9
@@ -466,6 +466,13 @@ def remove_permission(request):
|
||||
ungrant_access_to_object(domain, account)
|
||||
return ajax_simple_response(dict(status="ok"))
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def viewsettings(request, tplname='admin/settings_header.html'):
|
||||
return render(request, tplname, {
|
||||
"selection" : "settings"
|
||||
})
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def viewparameters(request, tplname='admin/parameters.html'):
|
||||
@@ -486,10 +493,10 @@ def viewparameters(request, tplname='admin/parameters.html'):
|
||||
tmp["params"] += [newdef]
|
||||
gparams += [tmp]
|
||||
|
||||
return render(request, tplname, {
|
||||
"selection" : "settings",
|
||||
return ajax_simple_response({
|
||||
"status" : "ok",
|
||||
"left_selection" : "parameters",
|
||||
"gparams" : gparams
|
||||
"content" : render_to_string(tplname, {"gparams" : gparams})
|
||||
})
|
||||
|
||||
@login_required
|
||||
@@ -500,7 +507,7 @@ def saveparameters(request):
|
||||
continue
|
||||
app, name = pname.split('.')
|
||||
parameters.save_admin(name, v, app=app)
|
||||
return ajax_simple_response(dict(status="ok", message=_("Parameters saved")))
|
||||
return ajax_simple_response(dict(status="ok", respmsg=_("Parameters saved")))
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
@@ -520,10 +527,9 @@ def viewextensions(request, tplname='admin/extensions.html'):
|
||||
ext["selection"] = False
|
||||
|
||||
tbl = ExtensionsTable(request, exts)
|
||||
return render(request, tplname, {
|
||||
"selection" : "settings",
|
||||
"left_selection" : "extensions",
|
||||
"extensions" : tbl
|
||||
return ajax_simple_response({
|
||||
"status" : "ok",
|
||||
"content" : render_to_string(tplname, {"extensions" : tbl})
|
||||
})
|
||||
|
||||
@login_required
|
||||
@@ -546,7 +552,7 @@ def saveextensions(request):
|
||||
ext.off()
|
||||
|
||||
return ajax_simple_response(dict(
|
||||
status="ok", message=_("Modifications applied."), reload=True
|
||||
status="ok", respmsg=_("Modifications applied.")
|
||||
))
|
||||
|
||||
def import_domain(user, row):
|
||||
|
||||
Reference in New Issue
Block a user