Fixed dynamic help text

This commit is contained in:
Marc Aymerich 2015-12-02 18:53:20 +00:00
parent c1dcca4f79
commit 05f1b1e672
6 changed files with 41 additions and 18 deletions

View file

@ -449,3 +449,6 @@ mkhomedir_helper or create ssh homes with bash.rc and such
# show base and total desglosed
# CLOSE&DOWNLOAD doesn't redirect to anything, confusing for users
# Reverse lOgHistory order by date (lastest first)

View file

@ -16,7 +16,7 @@ from .models import Address, Mailbox
logger = logging.getLogger(__name__)
class SieveFilteringMixin(object):
class SieveFilteringMixin:
def generate_filter(self, mailbox, context):
name, content = mailbox.get_filtering()
for box in re.findall(r'fileinto\s+"([^"]+)"', content):
@ -114,14 +114,14 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
self.append(textwrap.dedent("""
nohup bash -c '{ sleep 2 && killall -u %(user)s -s KILL; }' &> /dev/null &
killall -u %(user)s || true
# Restart because of Postfix SASL caches credentials
userdel %(user)s || true && RESTART_POSTFIX=1
# Restart because of Postfix SASL caching credentials
userdel %(user)s && RESTART_POSTFIX=1 || true
groupdel %(user)s || true""") % context
)
def commit(self):
self.append('[[ $RESTART_POSTFIX -eq 1 ]] && service postfix restart')
super(UNIXUserMaildirBackend, self).commit()
super().commit()
def get_context(self, mailbox):
context = {
@ -374,11 +374,11 @@ class PostfixAddressBackend(PostfixAddressVirtualDomainBackend):
)
def save(self, address):
context = super(PostfixAddressBackend, self).save(address)
context = super().save(address)
self.update_virtual_alias_maps(address, context)
def delete(self, address):
context = super(PostfixAddressBackend, self).save(address)
context = super().save(address)
self.exclude_virtual_alias_maps(context)
def commit(self):
@ -418,7 +418,7 @@ class DovecotMaildirDisk(ServiceMonitor):
)
def prepare(self):
super(DovecotMaildirDisk, self).prepare()
super().prepare()
current_date = self.current_date.strftime("%Y-%m-%d %H:%M:%S %Z")
self.append(textwrap.dedent("""\
function monitor () {

View file

@ -106,14 +106,33 @@ class PHPEnableFunctions(PHPAppOption):
def validate(self):
# Clean value removing spaces
self.instance.value = self.instance.value.replace(' ', '')
super(PHPEnableFunctions, self).validate()
super().validate()
class PHPDisableFunctions(PHPAppOption):
name = 'disable_functions'
verbose_name = _("Disable functions")
help_text = _("This directive allows you to disable certain functions for security reasons. "
"It takes on a comma-delimited list of function names. disable_functions is not "
"affected by Safe Mode. Default disabled fuctions include:<br>"
"<tt>%s</tt>") % ',<br>'.join([
','.join(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS[i:i+10])
for i in range(0, len(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS), 10)
])
regex = r'^[\w\.,-]+$'
comma_separated = True
def validate(self):
# Clean value removing spaces
self.instance.value = self.instance.value.replace(' ', '')
super().validate()
class PHPAllowURLInclude(PHPAppOption):
name = 'allow_url_include'
verbose_name = _("Allow URL include")
help_text = _("Allows the use of URL-aware fopen wrappers with include, include_once, require, "
"require_once (On or Off).")
"require_once (On or Off).")
regex = r'^(On|Off|on|off)$'

View file

@ -220,6 +220,7 @@ WEBAPPS_ENABLED_OPTIONS = Setting('WEBAPPS_ENABLED_OPTIONS', (
'orchestra.contrib.webapps.options.Timeout',
'orchestra.contrib.webapps.options.Processes',
'orchestra.contrib.webapps.options.PHPEnableFunctions',
'orchestra.contrib.webapps.options.PHPDisableFunctions',
'orchestra.contrib.webapps.options.PHPAllowURLInclude',
'orchestra.contrib.webapps.options.PHPAllowURLFopen',
'orchestra.contrib.webapps.options.PHPAutoAppendFile',

View file

@ -90,14 +90,14 @@ class PHPApp(AppType):
# Disable functions
if self.PHP_DISABLED_FUNCTIONS:
enable_functions = init_vars.pop('enable_functions', '')
if enable_functions or self.is_fpm:
disable_functions = set(init_vars.pop('disable_functions', '').split(','))
if disable_functions or enable_functions or self.is_fpm:
# FPM: Defining 'disable_functions' or 'disable_classes' will not overwrite previously
# defined php.ini values, but will append the new value
enable_functions = set(enable_functions.split(','))
disable_functions = []
for function in self.PHP_DISABLED_FUNCTIONS:
if function not in enable_functions:
disable_functions.append(function)
disable_functions.add(function)
init_vars['disable_functions'] = ','.join(disable_functions)
# Process timeout
if timeout:

View file

@ -1,24 +1,24 @@
{% load i18n admin_tools_menu_tags %}
{% load i18n admin_tools_menu_tags staticfiles %}
{% if menu.children %}
<script type="text/javascript" src="{{ media_url }}/admin_tools/js/utils.js"></script>
<script type="text/javascript" src="{% static 'admin_tools/js/utils.js' %}"></script>
<script type="text/javascript" charset="utf-8">
// Load js files syncronously and conditionally
var js_files = [
{
src : '{{ media_url }}/admin_tools/js/jquery/jquery.min.js',
src : '{% static "admin_tools/js/jquery/jquery.min.js" %}',
test: function() { return typeof(jQuery) == 'undefined'; }
},
{
src : '{{ media_url }}/admin_tools/js/json.min.js',
src : '{% static "admin_tools/js/json.min.js" %}',
test: function() { return typeof(JSON.stringify) == 'undefined'; }
},
{
src : '{{ media_url }}/admin_tools/js/menu.js',
src : '{% static "admin_tools/js/menu.js" %}',
test: function() { return true; }
}{% for js in menu.Media.js %},
{
src : '{{ media_url }}/{{ js }}',
src : '{% static js %}',
test: function() { return true; }
}{% endfor %}
];