datasource: organize items with optgroups in DataSourceSelectionWidget (#48283)
This commit is contained in:
parent
d01b3c2ce9
commit
71a4174d63
|
@ -58,14 +58,24 @@ class DataSourceSelectionWidget(CompositeWidget):
|
|||
if not value:
|
||||
value = {}
|
||||
|
||||
options = []
|
||||
if allow_named_sources:
|
||||
options.extend([(x.slug, x.name, x.slug) for x in NamedDataSource.select()])
|
||||
from wcs.carddef import CardDef
|
||||
options.extend([(t[2], t[1], t[2]) for t in CardDef.get_carddefs_as_data_source()])
|
||||
options.sort(key=lambda x: misc.simplify(x[1]))
|
||||
options = [(None, _('None'), None)]
|
||||
|
||||
options.insert(0, (None, _('None'), None))
|
||||
if allow_named_sources:
|
||||
from wcs.carddef import CardDef
|
||||
cards_options = [(t[2], t[1], t[2]) for t in CardDef.get_carddefs_as_data_source()]
|
||||
cards_options.sort(key=lambda x: misc.simplify(x[1]))
|
||||
if cards_options:
|
||||
options.append(OptGroup(_('Cards')))
|
||||
options.extend(cards_options)
|
||||
|
||||
nds_options = [(x.slug, x.name, x.slug) for x in NamedDataSource.select()]
|
||||
nds_options.sort(key=lambda x: misc.simplify(x[1]))
|
||||
if nds_options:
|
||||
options.append(OptGroup(_('Manually Configured Data Sources')))
|
||||
options.extend(nds_options)
|
||||
|
||||
if len(options) > 1:
|
||||
options.append(OptGroup(_('Generic Data Sources')))
|
||||
options.append(('json', _('JSON URL'), 'json'))
|
||||
if allow_jsonp:
|
||||
options.append(('jsonp', _('JSONP URL'), 'jsonp'))
|
||||
|
|
Loading…
Reference in New Issue