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

View File

@ -106,7 +106,26 @@ class PHPEnableFunctions(PHPAppOption):
def validate(self): def validate(self):
# Clean value removing spaces # Clean value removing spaces
self.instance.value = self.instance.value.replace(' ', '') 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): class PHPAllowURLInclude(PHPAppOption):

View File

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

View File

@ -90,14 +90,14 @@ class PHPApp(AppType):
# Disable functions # Disable functions
if self.PHP_DISABLED_FUNCTIONS: if self.PHP_DISABLED_FUNCTIONS:
enable_functions = init_vars.pop('enable_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 # FPM: Defining 'disable_functions' or 'disable_classes' will not overwrite previously
# defined php.ini values, but will append the new value # defined php.ini values, but will append the new value
enable_functions = set(enable_functions.split(',')) enable_functions = set(enable_functions.split(','))
disable_functions = []
for function in self.PHP_DISABLED_FUNCTIONS: for function in self.PHP_DISABLED_FUNCTIONS:
if function not in enable_functions: if function not in enable_functions:
disable_functions.append(function) disable_functions.add(function)
init_vars['disable_functions'] = ','.join(disable_functions) init_vars['disable_functions'] = ','.join(disable_functions)
# Process timeout # Process timeout
if 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 %} {% 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"> <script type="text/javascript" charset="utf-8">
// Load js files syncronously and conditionally // Load js files syncronously and conditionally
var js_files = [ 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'; } 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'; } 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; } test: function() { return true; }
}{% for js in menu.Media.js %}, }{% for js in menu.Media.js %},
{ {
src : '{{ media_url }}/{{ js }}', src : '{% static js %}',
test: function() { return true; } test: function() { return true; }
}{% endfor %} }{% endfor %}
]; ];