mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-16 09:34:03 +01:00
Merge branch 'master' into feature/deploy_with_extensions
Conflicts: modoboa/core/commands/deploy.py
This commit is contained in:
@@ -82,7 +82,7 @@ def check_for_new_version(user, include_all):
|
||||
return [{"id": "newversionavailable"}] if include_all else []
|
||||
return [{
|
||||
"id": "newversionavailable",
|
||||
"url": reverse("admin_index") + "#info/",
|
||||
"url": reverse("core:index") + "#info/",
|
||||
"text": _("New Modoboa version available"),
|
||||
"level": "info",
|
||||
}]
|
||||
|
||||
@@ -57,7 +57,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
("crypt", ugettext_lazy("crypt (weak)")),
|
||||
("plain", ugettext_lazy("plain (weak)"))],
|
||||
initial="sha512crypt",
|
||||
help_text=ugettext_lazy("Scheme used to crypt mailbox passwords")
|
||||
help_text=ugettext_lazy("Scheme used to crypt mailbox passwords"),
|
||||
widget=forms.Select(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
rounds_number = forms.IntegerField(
|
||||
@@ -66,13 +67,15 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
help_text=ugettext_lazy(
|
||||
"Number of rounds to use (only used by sha256crypt and "
|
||||
"sha512crypt). Must be between 1000 and 999999999, inclusive."
|
||||
)
|
||||
),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
secret_key = forms.CharField(
|
||||
label=ugettext_lazy("Secret key"),
|
||||
initial=random_key(),
|
||||
help_text=ugettext_lazy("Key used to encrypt/decrypt passwords")
|
||||
help_text=ugettext_lazy("Key used to encrypt/decrypt passwords"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
# LDAP specific settings
|
||||
@@ -82,13 +85,15 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
label=ugettext_lazy("Server address"),
|
||||
initial="localhost",
|
||||
help_text=ugettext_lazy(
|
||||
"The IP address of the DNS name of the LDAP server")
|
||||
"The IP address of the DNS name of the LDAP server"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_server_port = forms.IntegerField(
|
||||
label=ugettext_lazy("Server port"),
|
||||
initial=389,
|
||||
help_text=ugettext_lazy("The TCP port number used by the LDAP server")
|
||||
help_text=ugettext_lazy("The TCP port number used by the LDAP server"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_secured = YesNoField(
|
||||
@@ -104,7 +109,7 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
('directbind', ugettext_lazy("Direct bind"))],
|
||||
initial='searchbind',
|
||||
help_text=ugettext_lazy("Choose the authentication method to use"),
|
||||
widget=InlineRadioSelect
|
||||
widget=forms.Select(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_bind_dn = forms.CharField(
|
||||
@@ -114,7 +119,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
"The distinguished name to use when binding to the LDAP server. "
|
||||
"Leave empty for an anonymous bind"
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_bind_password = forms.CharField(
|
||||
@@ -124,7 +130,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
"The password to use when binding to the LDAP server "
|
||||
"(with 'Bind DN')"
|
||||
),
|
||||
widget=forms.PasswordInput(render_value=True),
|
||||
widget=forms.PasswordInput(
|
||||
attrs={"class": "form-control"}, render_value=True),
|
||||
required=False
|
||||
)
|
||||
|
||||
@@ -134,7 +141,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
help_text=ugettext_lazy(
|
||||
"The distinguished name of the search base used to find users"
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_search_filter = forms.CharField(
|
||||
@@ -144,7 +152,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
"An optional filter string (e.g. '(objectClass=person)'). "
|
||||
"In order to be valid, it must be enclosed in parentheses."
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_user_dn_template = forms.CharField(
|
||||
@@ -154,13 +163,15 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
"The template used to construct a user's DN. It should contain "
|
||||
"one placeholder (ie. %(user)s)"
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_password_attribute = forms.CharField(
|
||||
label=ugettext_lazy("Password attribute"),
|
||||
initial="userPassword",
|
||||
help_text=ugettext_lazy("The attribute used to store user passwords")
|
||||
help_text=ugettext_lazy("The attribute used to store user passwords"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_is_active_directory = YesNoField(
|
||||
@@ -177,7 +188,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
"Members of those LDAP Posix groups will be created as domain "
|
||||
"administrators. Use ';' characters to separate groups."
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_groups_search_base = forms.CharField(
|
||||
@@ -186,7 +198,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
help_text=ugettext_lazy(
|
||||
"The distinguished name of the search base used to find groups"
|
||||
),
|
||||
required=False
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
ldap_create_domain_mailbox = YesNoField(
|
||||
@@ -203,7 +216,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
top_notifications_check_interval = forms.IntegerField(
|
||||
label=_("Top notifications check interval"),
|
||||
initial=30,
|
||||
help_text=_("Interval between two top notification checks")
|
||||
help_text=_("Interval between two top notification checks"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
check_new_versions = YesNoField(
|
||||
@@ -216,13 +230,15 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
log_maximum_age = forms.IntegerField(
|
||||
label=ugettext_lazy("Maximum log record age"),
|
||||
initial=365,
|
||||
help_text=ugettext_lazy("The maximum age in days of a log record")
|
||||
help_text=ugettext_lazy("The maximum age in days of a log record"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
items_per_page = forms.IntegerField(
|
||||
label=ugettext_lazy("Items per page"),
|
||||
initial=30,
|
||||
help_text=ugettext_lazy("Number of displayed items per page")
|
||||
help_text=ugettext_lazy("Number of displayed items per page"),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
default_top_redirection = forms.ChoiceField(
|
||||
@@ -231,7 +247,8 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
initial="user",
|
||||
help_text=ugettext_lazy(
|
||||
"The default redirection used when no application is specified"
|
||||
)
|
||||
),
|
||||
widget=forms.Select(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
# Visibility rules
|
||||
@@ -369,5 +386,6 @@ class UserSettings(parameters.UserParametersForm):
|
||||
("fr", "français"), ("it", "italiano"),
|
||||
("nl", "nederlands"), ("pt", "português"),
|
||||
("ru", "русский"), ("sv", "svenska")],
|
||||
help_text=ugettext_lazy("Prefered language to display pages")
|
||||
help_text=ugettext_lazy("Prefered language to display pages"),
|
||||
widget=forms.Select(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.template import Context, Template
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
from modoboa.core.commands import Command
|
||||
|
||||
dbconn_tpl = """
|
||||
DBCONN_TPL = """
|
||||
'{{ conn_name }}': {
|
||||
'ENGINE': '{{ ENGINE }}',
|
||||
'NAME': '{{ NAME }}', # Or path to database file if using sqlite3.
|
||||
@@ -27,7 +27,13 @@ dbconn_tpl = """
|
||||
|
||||
|
||||
class DeployCommand(Command):
|
||||
help = "Create a fresh django project (calling startproject) and apply Modoboa specific settings."
|
||||
|
||||
"""The ``deploy`` command."""
|
||||
|
||||
help = (
|
||||
"Create a fresh django project (calling startproject)"
|
||||
" and apply Modoboa specific settings."
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DeployCommand, self).__init__(*args, **kwargs)
|
||||
@@ -58,6 +64,10 @@ class DeployCommand(Command):
|
||||
'--extensions', type=str, nargs='*',
|
||||
help='Deploy with those extensions already enabled'
|
||||
)
|
||||
self._parser.add_argument(
|
||||
'--devel', action='store_true', default=False,
|
||||
help='Create a development instance'
|
||||
)
|
||||
|
||||
def _exec_django_command(self, name, cwd, *args):
|
||||
"""Run a django command for the freshly created project
|
||||
@@ -134,7 +144,7 @@ class DeployCommand(Command):
|
||||
sys.path.append(".")
|
||||
django14 = False
|
||||
|
||||
t = Template(dbconn_tpl)
|
||||
t = Template(DBCONN_TPL)
|
||||
|
||||
if parsed_args.dburl:
|
||||
info = dj_database_url.config(default=parsed_args.dburl[0])
|
||||
@@ -176,13 +186,19 @@ class DeployCommand(Command):
|
||||
'Under which domain do you want to deploy modoboa? '
|
||||
)
|
||||
|
||||
bower_components_dir = os.path.realpath(
|
||||
os.path.join(os.path.dirname(__file__), "../../bower_components")
|
||||
)
|
||||
|
||||
mod = __import__(parsed_args.name, globals(), locals(), ['settings'])
|
||||
tpl = self._render_template(
|
||||
"%s/settings.py.tpl" % self._templates_dir, {
|
||||
'default_conn': default_conn, 'amavis_conn': amavis_conn,
|
||||
'secret_key': mod.settings.SECRET_KEY,
|
||||
'name': parsed_args.name, 'django14': django14,
|
||||
'allowed_host': allowed_host
|
||||
'allowed_host': allowed_host,
|
||||
'bower_components_dir': bower_components_dir,
|
||||
'devmode': parsed_args.devel
|
||||
}
|
||||
)
|
||||
with open("%s/settings.py" % path, "w") as fp:
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# Django settings for {{ name }} project.
|
||||
import os
|
||||
from logging.handlers import SysLogHandler
|
||||
{% if devmode %}
|
||||
from modoboa.core.dev_settings import *
|
||||
{% endif %}
|
||||
|
||||
DEBUG = False
|
||||
DEBUG = {{ devmode }}
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
MODOBOA_DIR = os.path.dirname(__file__)
|
||||
@@ -83,6 +86,7 @@ STATICFILES_DIRS = (
|
||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
"{{ bower_components_dir }}",
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Development settings
|
||||
import os
|
||||
|
||||
BOWER_COMPONENTS_ROOT = os.path.join(
|
||||
os.path.dirname(__file__), ".."
|
||||
)
|
||||
|
||||
BOWER_INSTALLED_APPS = (
|
||||
"jquery#1.9",
|
||||
"jquery-ui#1.11",
|
||||
"bootstrap#3.2.0",
|
||||
"bootstrap-select#1.6",
|
||||
"d3#3.3.13",
|
||||
"eonasdan-bootstrap-datetimepicker#3.1.3",
|
||||
"font-awesome#4.2.0",
|
||||
)
|
||||
@@ -3,7 +3,7 @@ from django.conf.urls import include
|
||||
|
||||
|
||||
class ModoExtension(object):
|
||||
"""Base extension class
|
||||
"""Base extension class.
|
||||
|
||||
Each Modoboa extension must inherit from this class to be
|
||||
considered as valid.
|
||||
@@ -86,8 +86,11 @@ class ExtensionsPool(object):
|
||||
try:
|
||||
baseurl = extinstance.url \
|
||||
if extinstance.url is not None else extname
|
||||
result += [(r'^%s/' % (baseurl),
|
||||
include("%s.urls" % extinstance.__module__))]
|
||||
result += [
|
||||
(r'^%s/' % (baseurl),
|
||||
include("%s.urls" % extinstance.__module__,
|
||||
namespace=extname))
|
||||
]
|
||||
except ImportError:
|
||||
# No urls for this extension
|
||||
pass
|
||||
|
||||
@@ -8,11 +8,11 @@ from modoboa.lib import parameters
|
||||
class LoginForm(forms.Form):
|
||||
username = forms.CharField(
|
||||
label=ugettext_lazy("Username"),
|
||||
widget=forms.TextInput(attrs={"class": "input-block-level"})
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=ugettext_lazy("Password"),
|
||||
widget=forms.PasswordInput(attrs={"class": "input-block-level"})
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
rememberme = forms.BooleanField(
|
||||
initial=False,
|
||||
@@ -23,20 +23,24 @@ class LoginForm(forms.Form):
|
||||
class ProfileForm(forms.ModelForm):
|
||||
oldpassword = forms.CharField(
|
||||
label=ugettext_lazy("Old password"), required=False,
|
||||
widget=forms.PasswordInput
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
newpassword = forms.CharField(
|
||||
label=ugettext_lazy("New password"), required=False,
|
||||
widget=forms.PasswordInput
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
confirmation = forms.CharField(
|
||||
label=ugettext_lazy("Confirmation"), required=False,
|
||||
widget=forms.PasswordInput
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ("first_name", "last_name")
|
||||
widgets = {
|
||||
'first_name': forms.TextInput(attrs={'class': 'form-control'}),
|
||||
'last_name': forms.TextInput(attrs={'class': 'form-control'})
|
||||
}
|
||||
|
||||
def __init__(self, update_password, *args, **kwargs):
|
||||
super(ProfileForm, self).__init__(*args, **kwargs)
|
||||
|
||||
+14
-1
@@ -94,7 +94,20 @@ class User(PermissionsMixin):
|
||||
super(User, self).delete()
|
||||
|
||||
def _crypt_password(self, raw_value):
|
||||
scheme = parameters.get_admin("PASSWORD_SCHEME")
|
||||
"""Crypt the local password using the appropriate scheme.
|
||||
|
||||
In case we don't find the scheme (for example when the
|
||||
management framework is used), we load the parameters and try
|
||||
one more time.
|
||||
|
||||
"""
|
||||
try:
|
||||
scheme = parameters.get_admin("PASSWORD_SCHEME")
|
||||
except parameters.NotDefined:
|
||||
from modoboa.core import load_core_settings
|
||||
load_core_settings()
|
||||
scheme = parameters.get_admin("PASSWORD_SCHEME")
|
||||
|
||||
if type(raw_value) is unicode:
|
||||
raw_value = raw_value.encode("utf-8")
|
||||
return get_password_hasher(scheme.upper())().encrypt(raw_value)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#uprefs_content .form-horizontal .control-label {
|
||||
margin-left: 20px;
|
||||
text-align: left;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
#uprefs_content > .form-horizontal .controls {
|
||||
margin-left: 240px;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Return an instance of Settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options - instance options
|
||||
*/
|
||||
var Settings = function(options) {
|
||||
TwocolsNav.call(this, options);
|
||||
};
|
||||
|
||||
Settings.prototype = {
|
||||
defaults: {
|
||||
main_table_id: "logs_table",
|
||||
eor_message: gettext("No more log entry to show")
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.options = $.extend({}, this.defaults, options);
|
||||
TwocolsNav.prototype.initialize.call(this, this.options);
|
||||
this.navobj.register_callback(
|
||||
"logs", $.proxy(this.logs_callback, this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Navigation callback: logs.
|
||||
*
|
||||
*/
|
||||
logs_callback: function(data) {
|
||||
this.select_left_menu();
|
||||
if (data.content) {
|
||||
$('#' + this.options.divid).html(data.content);
|
||||
}
|
||||
this.update_listing(data);
|
||||
}
|
||||
};
|
||||
|
||||
Settings.prototype = $.extend({}, TwocolsNav.prototype, Settings.prototype);
|
||||
@@ -4,6 +4,7 @@ from modoboa.lib import tables
|
||||
|
||||
class ExtensionsTable(tables.Table):
|
||||
idkey = "id"
|
||||
styles = "table-hover"
|
||||
selection = tables.SelectionColumn("selection", width="4%", header=False)
|
||||
label = tables.Column("label", label=ugettext_lazy("Name"), width="15%")
|
||||
version = tables.Column(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% load i18n %}{% load url from future %}
|
||||
<h2>{% trans "Extensions" %} <small>{% trans "Choose the extension(s) to use" %}</small></h2><hr />
|
||||
<form id="settings_form" method="POST" action="{% url 'modoboa.core.views.admin.saveextensions' %}">{% csrf_token %}
|
||||
<form id="settings_form" method="POST" action="{% url 'core:extension_save' %}">{% csrf_token %}
|
||||
{{ extensions|safe }}
|
||||
</form>
|
||||
<a href="#" class="btn btn-primary" id="update" name="update">{% trans 'Save' %}</a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% load i18n core_tags %}
|
||||
{% load i18n %}
|
||||
<h2>{% trans "Logs" %} <small>{% trans "Previously on Modoboa..." %}</small></h2><hr>
|
||||
<table class="table">
|
||||
<table id="logs_table" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sortable" data-sort_order="date_created" width="20%">{% trans "Date" %}</th>
|
||||
@@ -10,11 +10,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for l in logs %}<tr>
|
||||
<td>{{ l.date_created }}</td>
|
||||
<td>{{ l.level|colorize_level|safe }}</td>
|
||||
<td>{{ l.logger }}</td>
|
||||
<td>{{ l.message|tohtml|safe }}</td>
|
||||
</tr>{% endfor %}
|
||||
{% include "core/logs_page.html" %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{% load core_tags %}
|
||||
|
||||
{% for l in logs %}
|
||||
<tr>
|
||||
<td>{{ l.date_created }}</td>
|
||||
<td>{{ l.level|colorize_level|safe }}</td>
|
||||
<td>{{ l.logger }}</td>
|
||||
<td>{{ l.message|tohtml|safe }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load i18n lib_tags %}{% load url from future %}
|
||||
<h2>{% trans "Parameters" %} <small>{% trans "Configure Modoboa" %}</small></h2><hr />
|
||||
<form id="settings_form" method="POST" action="{% url 'modoboa.core.views.admin.saveparameters' %}" class="form-horizontal">{% csrf_token %}
|
||||
<form id="settings_form" method="POST" action="{% url 'core:parameter_save' %}" class="form-horizontal">{% csrf_token %}
|
||||
{% include "common/parameters.html" %}
|
||||
</form>
|
||||
<hr>
|
||||
<a href="#" class="btn btn-primary" id="update" name="update">{% trans 'Save' %}</a>
|
||||
<a href="#" class="btn btn-primary col-lg-offset-7 col-md-offset-7 col-sm-offset-7 col-lg-1 col-md-2 col-sm-2" id="update" name="update">{% trans 'Save' %}</a>
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
{% extends "twocols.html" %}
|
||||
{% load i18n lib_tags core_tags %}
|
||||
{% load static %}
|
||||
|
||||
{% block pagetitle %}{% trans "Modoboa settings" %}{% endblock %}
|
||||
{% block html_head %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/settings.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.sortable.css" />
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/history.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/listing.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/twocols_nav.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.sortable.js"></script>
|
||||
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/settings.css' %}" />
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery.sortable.css' %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script type="text/javascript" src="{% static 'js/jquery.infinitescroll.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/history.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/listing.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/twocols_nav.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/jquery.sortable.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'core/js/settings.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var settings = new TwocolsNav({
|
||||
var settings = new Settings({
|
||||
deflocation: "parameters/",
|
||||
formid: "settings_form",
|
||||
divid: "settings_content",
|
||||
reload_exceptions: ["extensions"]
|
||||
reload_exceptions: ["extensions"],
|
||||
load_page_url: "{% url 'core:logs_page' %}"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block leftcol %}<div class="well sidebar-nav">{% admin_menu left_selection user %}</div>{% endblock %}
|
||||
|
||||
{% block leftcol %}{% admin_menu left_selection user %}{% endblock %}
|
||||
|
||||
{% block apparea %}<div id="settings_content"></div>{% endblock %}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
{% extends "twocols.html" %}{% load i18n core_tags lib_tags %}
|
||||
{% load static %}
|
||||
|
||||
{% block pagetitle %}{% trans "Settings" %}{% endblock %}
|
||||
{% block html_head %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}core/css/userprefs.css" />
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/history.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/listing.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/twocols_nav.js"></script>
|
||||
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'core/css/userprefs.css' %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script type="text/javascript" src="{% static 'js/history.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/listing.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/twocols_nav.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
{{ extrajs|safe }}
|
||||
$(document).ready(function() {
|
||||
@@ -17,5 +23,7 @@ $(document).ready(function() {
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block leftcol %}<div class="well sidebar-nav">{% uprefs_menu left_selection user %}</div>{% endblock %}
|
||||
|
||||
{% block leftcol %}{% uprefs_menu left_selection user %}{% endblock %}
|
||||
|
||||
{% block apparea %}<div id="uprefs_content"></div>{% endblock %}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{% load i18n %}{% load url from future %}
|
||||
<h2>{% trans "Preferences" %} <small>{% trans "Customize Modoboa" %}</small></h2>
|
||||
<hr>
|
||||
<form class="form-horizontal" method="POST" action="{% url 'modoboa.core.views.user.preferences' %}"
|
||||
<form class="form-horizontal" method="POST" action="{% url 'core:user_preferences' %}"
|
||||
id="uprefs_form">{% csrf_token %}
|
||||
{% include "common/parameters.html" %}
|
||||
<hr>
|
||||
<button type="submit" class="btn btn-primary" id="update" name="update">{% trans 'Save' %}</button>
|
||||
<button type="submit" class="btn btn-primary col-lg-offset-8 col-md-offset-7 col-sm-offset-7 col-lg-1 col-md-2 col-sm-2" id="update" name="update">{% trans 'Save' %}</button>
|
||||
</form>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{% load i18n lib_tags %}{% load url from future %}
|
||||
{% load i18n form_tags %}{% load url from future %}
|
||||
<h2>{% trans "Profile" %} <small>{% trans "Update your personal information" %}</small></h2>
|
||||
<hr>
|
||||
<form class="form-horizontal" method="POST" action="{% url 'modoboa.core.views.user.profile' %}"
|
||||
<form class="form-horizontal" method="POST" action="{% url 'core:user_profile' %}"
|
||||
id="uprefs_form">{% csrf_token %}
|
||||
{% render_form form %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary" id="update" name="update">{% trans 'Update' %}</button>
|
||||
<button type="submit" class="btn btn-primary col-lg-offset-8 col-md-offset-7 col-sm-offset-7 col-lg-1 col-md-2 col-sm-2" id="update" name="update">{% trans 'Update' %}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -19,7 +19,7 @@ def core_menu(selection, user):
|
||||
entries += [
|
||||
{"name": "settings",
|
||||
"label": _("Modoboa"),
|
||||
"url": reverse("modoboa.core.views.admin.viewsettings")}
|
||||
"url": reverse("core:index")}
|
||||
]
|
||||
|
||||
if not len(entries):
|
||||
@@ -63,7 +63,7 @@ def admin_menu(selection, user):
|
||||
]
|
||||
return render_to_string('common/menu.html', {
|
||||
"entries": entries,
|
||||
"css": "nav nav-list",
|
||||
"css": "nav nav-sidebar",
|
||||
"selection": selection,
|
||||
"user": user
|
||||
})
|
||||
@@ -73,22 +73,22 @@ def admin_menu(selection, user):
|
||||
def user_menu(user, selection):
|
||||
entries = [
|
||||
{"name": "user",
|
||||
"img": "icon-user icon-white",
|
||||
"img": "fa fa-user",
|
||||
"label": user.fullname,
|
||||
"menu": [
|
||||
{"name": "settings",
|
||||
"img": "icon-list",
|
||||
"img": "fa fa-list",
|
||||
"label": _("Settings"),
|
||||
"url": reverse("modoboa.core.views.user.index")}
|
||||
"url": reverse("core:user_index")}
|
||||
]}
|
||||
]
|
||||
|
||||
entries[0]["menu"] += \
|
||||
events.raiseQueryEvent("UserMenuDisplay", "options_menu", user) \
|
||||
+ [{"name": "logout",
|
||||
"url": reverse("modoboa.core.views.auth.dologout"),
|
||||
"url": reverse("core:logout"),
|
||||
"label": _("Logout"),
|
||||
"img": "icon-off"}]
|
||||
"img": "fa fa-sign-out"}]
|
||||
|
||||
return render_to_string("common/menulist.html", {
|
||||
"selection": selection, "entries": entries, "user": user
|
||||
@@ -111,7 +111,7 @@ def uprefs_menu(selection, user):
|
||||
entries = sorted(entries, key=lambda e: e["label"])
|
||||
return render_to_string('common/menu.html', {
|
||||
"entries": entries,
|
||||
"css": "nav nav-list",
|
||||
"css": "nav nav-sidebar",
|
||||
"selection": selection,
|
||||
"user": user
|
||||
})
|
||||
@@ -119,10 +119,11 @@ def uprefs_menu(selection, user):
|
||||
|
||||
@register.filter
|
||||
def colorize_level(level):
|
||||
"""A simple filter a text using a boostrap color."""
|
||||
classes = {
|
||||
"INFO": "text-info",
|
||||
"WARNING": "text-warning",
|
||||
"CRITICAL": "text-error"
|
||||
"CRITICAL": "text-danger"
|
||||
}
|
||||
if not level in classes:
|
||||
return level
|
||||
@@ -131,7 +132,8 @@ def colorize_level(level):
|
||||
|
||||
@register.filter
|
||||
def tohtml(message):
|
||||
return re.sub("'(.*?)'", "<strong>\g<1></strong>", message)
|
||||
"""Simple tag to format a text using HTML."""
|
||||
return re.sub(r"'(.*?)'", "<strong>\g<1></strong>", message)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
|
||||
@@ -25,7 +25,7 @@ class ProfileTestCase(ModoTestCase):
|
||||
* The default admin changes his password (no associated Mailbox)
|
||||
* A normal user changes his password
|
||||
"""
|
||||
self.ajax_post(reverse("modoboa.core.views.user.profile"),
|
||||
self.ajax_post(reverse("core:user_profile"),
|
||||
{"oldpassword": "password",
|
||||
"newpassword": "titi", "confirmation": "titi"})
|
||||
self.clt.logout()
|
||||
@@ -38,7 +38,7 @@ class ProfileTestCase(ModoTestCase):
|
||||
)
|
||||
|
||||
self.ajax_post(
|
||||
reverse("modoboa.core.views.user.profile"),
|
||||
reverse("core:user_profile"),
|
||||
{"oldpassword": "toto",
|
||||
"newpassword": "tutu", "confirmation": "tutu"}
|
||||
)
|
||||
@@ -67,21 +67,21 @@ class ModoboaAdminCommandTestCase(TestCase):
|
||||
self.workdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
exec_cmd("rm -rf {}".format(self.workdir))
|
||||
exec_cmd("rm -rf {0}".format(self.workdir))
|
||||
|
||||
def _test_maps_generation(self, engine, categories=None):
|
||||
if categories is None:
|
||||
categories = ["std", "autoreply", "relaydomains"]
|
||||
dburl = "{}://user:password@localhost/testdb".format(engine)
|
||||
dburl = "{0}://user:password@localhost/testdb".format(engine)
|
||||
code, output = exec_cmd(
|
||||
"modoboa-admin.py postfix_maps --categories {} --dburl {} {}".format(
|
||||
"modoboa-admin.py postfix_maps --categories {0} --dburl {1} {2}".format(
|
||||
" ".join(categories), dburl, self.workdir
|
||||
)
|
||||
)
|
||||
self.assertEqual(code, 0)
|
||||
for category in categories:
|
||||
for mapfile in self.MAP_FILES[category]:
|
||||
path = "{}/{}".format(self.workdir, mapfile)
|
||||
path = "{0}/{1}".format(self.workdir, mapfile)
|
||||
self.assertTrue(os.path.exists(path))
|
||||
with open(path) as fpo:
|
||||
content = fpo.read()
|
||||
|
||||
+22
-12
@@ -4,23 +4,33 @@ from django.conf.urls import patterns, url
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
|
||||
(r'^accounts/login/$', 'modoboa.core.views.auth.dologin'),
|
||||
(r'^accounts/logout/$', 'modoboa.core.views.auth.dologout'),
|
||||
url(r'^accounts/login/$', 'modoboa.core.views.auth.dologin',
|
||||
name="login"),
|
||||
url(r'^accounts/logout/$', 'modoboa.core.views.auth.dologout',
|
||||
name="logout"),
|
||||
|
||||
url(r'^core/$', 'modoboa.core.views.admin.viewsettings',
|
||||
name="admin_index"),
|
||||
(r'^core/parameters/$', 'modoboa.core.views.admin.viewparameters'),
|
||||
(r'^core/parameters/save/$', 'modoboa.core.views.admin.saveparameters'),
|
||||
(r'^core/extensions/$', 'modoboa.core.views.admin.viewextensions'),
|
||||
(r'^core/extensions/save/$', 'modoboa.core.views.admin.saveextensions'),
|
||||
name="index"),
|
||||
url(r'^core/parameters/$', 'modoboa.core.views.admin.viewparameters',
|
||||
name="parameter_listl"),
|
||||
url(r'^core/parameters/save/$', 'modoboa.core.views.admin.saveparameters',
|
||||
name="parameter_save"),
|
||||
url(r'^core/extensions/$', 'modoboa.core.views.admin.viewextensions',
|
||||
name="extension_list"),
|
||||
url(r'^core/extensions/save/$', 'modoboa.core.views.admin.saveextensions',
|
||||
name="extension_save"),
|
||||
url(r'^core/info/$', 'modoboa.core.views.admin.information',
|
||||
name="information"),
|
||||
(r'^core/logs/$', 'modoboa.core.views.admin.logs'),
|
||||
url(r'^core/logs/$', 'modoboa.core.views.admin.logs', name="log_list"),
|
||||
url(r'^core/logs/page/$', 'modoboa.core.views.admin.logs_page',
|
||||
name="logs_page"),
|
||||
url(r'^core/top_notifications/check/$',
|
||||
'modoboa.core.views.admin.check_top_notifications',
|
||||
name='check_top_notifications'),
|
||||
name='top_notifications_check'),
|
||||
|
||||
(r'^user/$', 'modoboa.core.views.user.index'),
|
||||
(r'^user/preferences/$', 'modoboa.core.views.user.preferences'),
|
||||
(r'^user/profile/$', 'modoboa.core.views.user.profile'),
|
||||
url(r'^user/$', 'modoboa.core.views.user.index', name="user_index"),
|
||||
url(r'^user/preferences/$', 'modoboa.core.views.user.preferences',
|
||||
name="user_preferences"),
|
||||
url(r'^user/profile/$', 'modoboa.core.views.user.profile',
|
||||
name="user_profile"),
|
||||
)
|
||||
|
||||
+38
-12
@@ -101,27 +101,53 @@ def information(request, tplname="core/information.html"):
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def logs(request, tplname="core/logs.html"):
|
||||
from modoboa.lib.templatetags.lib_tags import pagination_bar
|
||||
|
||||
def get_logs_page(request, page_id=None):
|
||||
"""Return a page of logs."""
|
||||
sort_order, sort_dir = get_sort_order(
|
||||
request.GET, "date_created",
|
||||
allowed_values=['date_created', 'level', 'logger', 'message']
|
||||
)
|
||||
page = get_listing_page(
|
||||
if page_id is None:
|
||||
page_id = request.GET.get("page", None)
|
||||
if page_id is None:
|
||||
return None
|
||||
return get_listing_page(
|
||||
Log.objects.all().order_by("%s%s" % (sort_dir, sort_order)),
|
||||
request.GET.get("page", 1)
|
||||
page_id
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def logs(request, tplname="core/logs.html"):
|
||||
"""Return a list of log entries.
|
||||
|
||||
This view is only called the first time the page is displayed.
|
||||
|
||||
"""
|
||||
page = get_logs_page(request, 1)
|
||||
return render_to_json_response({
|
||||
"content": render_to_string(tplname, {
|
||||
"logs": page.object_list,
|
||||
}),
|
||||
"page": page.number,
|
||||
"paginbar": pagination_bar(page),
|
||||
"callback": "logs",
|
||||
"content": render_to_string(tplname, {"logs": page.object_list}),
|
||||
"page": page.number
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def logs_page(request, tplname="core/logs_page.html"):
|
||||
"""Return a page containing logs."""
|
||||
page = get_logs_page(request)
|
||||
if page is None:
|
||||
context = {"length": 0}
|
||||
else:
|
||||
context = {
|
||||
"rows": render_to_string(tplname, {"logs": page.object_list}),
|
||||
"pages": [page.number]
|
||||
}
|
||||
return render_to_json_response(context)
|
||||
|
||||
|
||||
@login_required
|
||||
def check_top_notifications(request):
|
||||
"""
|
||||
|
||||
@@ -36,14 +36,17 @@ def dologin(request):
|
||||
nextlocation = request.POST.get("next", None)
|
||||
if nextlocation is None or nextlocation == "None":
|
||||
if user.group == "SimpleUsers":
|
||||
nextlocation = reverse("modoboa.lib.webutils.topredirection")
|
||||
nextlocation = reverse("topredirection")
|
||||
else:
|
||||
nextlocation = reverse("domains")
|
||||
nextlocation = reverse("admin:domain_list")
|
||||
return HttpResponseRedirect(nextlocation)
|
||||
error = _("Your username and password didn't match. Please try again.")
|
||||
logger.warning("Failed connection attempt from '%(addr)s' as user '%(user)s'" \
|
||||
% {"addr": request.META["REMOTE_ADDR"],
|
||||
"user": form.cleaned_data["username"]})
|
||||
error = _(
|
||||
"Your username and password didn't match. Please try again.")
|
||||
logger.warning(
|
||||
"Failed connection attempt from '%(addr)s' as user '%(user)s'" \
|
||||
% {"addr": request.META["REMOTE_ADDR"],
|
||||
"user": form.cleaned_data["username"]}
|
||||
)
|
||||
|
||||
nextlocation = request.POST.get("next", None)
|
||||
httpcode = 401
|
||||
@@ -68,4 +71,4 @@ def dologout(request):
|
||||
logger = logging.getLogger("modoboa.auth")
|
||||
logger.info(_("User '%s' logged out" % request.user.username))
|
||||
logout(request)
|
||||
return HttpResponseRedirect(reverse(dologin))
|
||||
return HttpResponseRedirect(reverse("core:login"))
|
||||
|
||||
Reference in New Issue
Block a user