Merge branch 'feature/show_config' into versions/next
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
+3
-1
@@ -18,7 +18,9 @@
|
|||||||
* Increase the size of the workflow preview image.
|
* Increase the size of the workflow preview image.
|
||||||
* Center the workflow preview image.
|
* Center the workflow preview image.
|
||||||
* Move the noop OCR backend to the right place.
|
* Move the noop OCR backend to the right place.
|
||||||
|
* Add new management command to display the current configuration
|
||||||
|
settings.
|
||||||
|
* Default the YAML flow format to False which never uses inline.
|
||||||
|
|
||||||
3.1.7 (2018-10-14)
|
3.1.7 (2018-10-14)
|
||||||
==================
|
==================
|
||||||
|
|||||||
@@ -92,16 +92,18 @@ class Setting(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dump_data(cls):
|
def dump_data(cls, filter_term=None, namespace=None):
|
||||||
dictionary = {}
|
dictionary = {}
|
||||||
|
|
||||||
for setting in cls.get_all():
|
for setting in cls.get_all():
|
||||||
if isinstance(setting.value, Promise):
|
if (namespace and setting.namespace.name == namespace) or not namespace:
|
||||||
dictionary[setting.global_name] = force_text(setting.value)
|
if (filter_term and filter_term.lower() in setting.global_name.lower()) or not filter_term:
|
||||||
else:
|
if isinstance(setting.value, Promise):
|
||||||
dictionary[setting.global_name] = setting.value
|
dictionary[setting.global_name] = force_text(setting.value)
|
||||||
|
else:
|
||||||
|
dictionary[setting.global_name] = setting.value
|
||||||
|
|
||||||
return yaml.safe_dump(dictionary)
|
return yaml.safe_dump(dictionary, default_flow_style=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, global_name):
|
def get(cls, global_name):
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.core import management
|
||||||
|
|
||||||
|
from ...classes import Setting
|
||||||
|
|
||||||
|
|
||||||
|
class Command(management.BaseCommand):
|
||||||
|
help = 'Display the current settings.'
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
dest='filter_term', nargs='?', help='Use this term to filter the '
|
||||||
|
'list of settings.'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--namespace', action='store', dest='namespace',
|
||||||
|
help='Name (not label) of the namespace for which to filter the '
|
||||||
|
'list of settings. Names are lowercase with words separated by '
|
||||||
|
'underscore.'
|
||||||
|
)
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
self.stdout.write(
|
||||||
|
Setting.dump_data(
|
||||||
|
namespace=options.get('namespace'),
|
||||||
|
filter_term=options.get('filter_term')
|
||||||
|
)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user