general: add option to have submission channel on global listing (#14098) #813
|
@ -1001,3 +1001,17 @@ def test_i18n(pub):
|
|||
# check language selection is now fixed
|
||||
resp = app.get('/backoffice/settings/language')
|
||||
assert resp.form['language'].options == [('English', True, 'English')]
|
||||
|
||||
|
||||
def test_submission_channels(pub):
|
||||
create_superuser(pub)
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/settings/submission-channels')
|
||||
resp.form['include-in-global-listing'].checked = True
|
||||
resp = resp.form.submit('submit')
|
||||
|
||||
pub.reload_cfg()
|
||||
assert pub.cfg['submission-channels']['include-in-global-listing'] is True
|
||||
|
||||
resp = app.get('/backoffice/settings/submission-channels')
|
||||
assert resp.form['include-in-global-listing'].checked
|
||||
|
|
|
@ -2735,7 +2735,7 @@ def test_api_geojson_formdata(pub, local_user):
|
|||
resp = get_app(pub).get(sign_uri('/api/forms/test/geojson?full=on', user=local_user))
|
||||
assert len(resp.json['features']) == 10
|
||||
display_fields = resp.json['features'][0]['properties']['display_fields']
|
||||
assert len(display_fields) == 8
|
||||
assert len(display_fields) == 9
|
||||
field_varnames = [f['varname'] for f in display_fields]
|
||||
assert 'foobar' in field_varnames
|
||||
|
||||
|
|
|
@ -3138,14 +3138,11 @@ def test_global_listing(pub):
|
|||
assert formdata.get_url(backoffice=True) in resp.text
|
||||
assert 'digest of number <%s>' % formdata.id_display in resp.text
|
||||
|
||||
# check a Channel column is added when welco is available
|
||||
# check a Channel column is added when not enabled
|
||||
assert 'Channel' not in resp.text
|
||||
|
||||
if not pub.site_options.has_section('variables'):
|
||||
pub.site_options.add_section('variables')
|
||||
pub.site_options.set('variables', 'welco_url', 'xxx')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
pub.cfg['submission-channels'] = {'include-in-global-listing': True}
|
||||
pub.write_cfg()
|
||||
|
||||
resp = app.get('/backoffice/management/listing?limit=500')
|
||||
formdata = formdef.data_class().select(lambda x: x.status == 'wf-new')[0]
|
||||
|
|
|
@ -70,7 +70,6 @@ def test_backoffice_columns(pub):
|
|||
resp = app.get('/backoffice/management/form-title/')
|
||||
assert resp.text.count('</th>') == 7 # five columns
|
||||
resp.forms['listing-settings']['1'].checked = False
|
||||
assert 'submission_channel' not in resp.forms['listing-settings'].fields
|
||||
assert 'last_update_time' in resp.forms['listing-settings'].fields
|
||||
resp = resp.forms['listing-settings'].submit()
|
||||
assert resp.text.count('</th>') == 6 # fixe columns
|
||||
|
@ -93,12 +92,6 @@ def test_backoffice_channel_column(pub):
|
|||
role = pub.role_class(name='test')
|
||||
role.store()
|
||||
|
||||
if not pub.site_options.has_section('variables'):
|
||||
pub.site_options.add_section('variables')
|
||||
pub.site_options.set('variables', 'welco_url', 'xxx')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form-title'
|
||||
|
@ -534,6 +527,7 @@ def test_backoffice_block_columns(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Block / card field',
|
||||
|
@ -558,6 +552,7 @@ def test_backoffice_block_columns(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Block / card field',
|
||||
|
@ -617,6 +612,7 @@ def test_backoffice_block_email_column(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Anonymised',
|
||||
|
@ -681,6 +677,7 @@ def test_backoffice_block_bool_column(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Anonymised',
|
||||
|
@ -741,6 +738,7 @@ def test_backoffice_block_date_column(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Anonymised',
|
||||
|
@ -806,6 +804,7 @@ def test_backoffice_block_file_column(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Anonymised',
|
||||
|
@ -867,6 +866,7 @@ def test_backoffice_block_text_column(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
'Anonymised',
|
||||
|
@ -929,6 +929,7 @@ def test_backoffice_block_column_position(pub):
|
|||
'Last Modified',
|
||||
'User Label',
|
||||
'Status',
|
||||
'Channel',
|
||||
'Foo',
|
||||
'Block',
|
||||
'Block / Test',
|
||||
|
@ -1082,6 +1083,7 @@ def test_backoffice_digest_column(pub):
|
|||
'User Label',
|
||||
'Status',
|
||||
'Digest',
|
||||
'Channel',
|
||||
'field',
|
||||
'Anonymised',
|
||||
]
|
||||
|
|
|
@ -287,12 +287,6 @@ def test_backoffice_export_long_listings(pub, threshold):
|
|||
|
||||
|
||||
def test_backoffice_csv_export_channel(pub):
|
||||
if not pub.site_options.has_section('variables'):
|
||||
pub.site_options.add_section('variables')
|
||||
pub.site_options.set('variables', 'welco_url', 'xxx')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
|
||||
create_superuser(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
|
|
|
@ -479,6 +479,7 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
('data-sources', 'data_sources'),
|
||||
'wscalls',
|
||||
('api-access', 'api_access'),
|
||||
('submission-channels', 'submission_channels'),
|
||||
]
|
||||
|
||||
emails = EmailsDirectory()
|
||||
|
@ -627,6 +628,11 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
_('Geolocation'),
|
||||
_('Configure geolocation'),
|
||||
)
|
||||
if enabled('submission-channels'):
|
||||
r += htmltext('<dt><a href="submission-channels">%s</a></dt> <dd>%s</dd>') % (
|
||||
_('Submission channels'),
|
||||
_('Configure submission channels related options'),
|
||||
|
||||
)
|
||||
if enabled('users'):
|
||||
r += htmltext('<dt><a href="users/">%s</a></dt> <dd>%s</dd>') % (_('Users'), _('Configure users'))
|
||||
else:
|
||||
|
@ -1315,6 +1321,36 @@ $('#form_default-zoom-level').on('change', function() {
|
|||
)
|
||||
return redirect('.')
|
||||
|
||||
def submission_channels(self):
|
||||
form = Form(enctype='multipart/form-data')
|
||||
submission_channels_cfg = get_cfg('submission-channels', {})
|
||||
form.add(
|
||||
CheckboxWidget,
|
||||
'include-in-global-listing',
|
||||
title=_('Include submission channel column in global listing'),
|
||||
value=submission_channels_cfg.get('include-in-global-listing'),
|
||||
)
|
||||
fpeters
commented
Ça démarrer avec une seule case à cocher mais l'écran servira pour d'autres options via d'autres tickets. Ça démarrer avec une seule case à cocher mais l'écran servira pour d'autres options via d'autres tickets.
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
||||
if form.get_widget('cancel').parse():
|
||||
return redirect('.')
|
||||
|
||||
if not form.is_submitted() or form.has_errors():
|
||||
get_response().breadcrumb.append(('submission-channels', _('Submission channels')))
|
||||
get_response().set_title(_('Submission channels'))
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<h2>%s</h2>') % _('Submission channels')
|
||||
r += form.render()
|
||||
return r.getvalue()
|
||||
else:
|
||||
cfg_submit(
|
||||
form,
|
||||
'submission-channels',
|
||||
('include-in-global-listing',),
|
||||
)
|
||||
return redirect('.')
|
||||
|
||||
|
||||
class FileTypeUpdateAfterJob(AfterJob):
|
||||
def done_action_url(self):
|
||||
|
|
|
@ -335,7 +335,7 @@ class ManagementDirectory(Directory):
|
|||
},
|
||||
)
|
||||
|
||||
if bool(get_publisher().get_site_option('welco_url', 'variables')):
|
||||
if get_cfg('submission-channels', {}).get('include-in-global-listing'):
|
||||
form.add(
|
||||
SingleSelectWidget,
|
||||
'submission_channel',
|
||||
|
@ -616,7 +616,7 @@ class ManagementDirectory(Directory):
|
|||
get_request().form['offset'] = '0'
|
||||
return redirect('listing?' + urllib.parse.urlencode(get_request().form))
|
||||
formdatas = sql.AnyFormData.select(criterias, order_by=order_by, limit=limit, offset=offset)
|
||||
include_submission_channel = bool(get_publisher().get_site_option('welco_url', 'variables'))
|
||||
include_submission_channel = get_cfg('submission-channels', {}).get('include-in-global-listing')
|
||||
fpeters
commented
Plutôt que regarder si welco_url existe, on regarde la nouvelle case à cocher. À noter que ça fait un certain temps que welco_url n'est plus posée, même avec welco déployé (#31683, il y a 4 ans); il y aura peut-être quelques endroits qui avaient welco_url, et perdront donc la colonne avec ce patch, si ça arrive, et que quelqu'un s'en rend compte, il y aura juste à cocher la case. Plutôt que regarder si welco_url existe, on regarde la nouvelle case à cocher.
À noter que ça fait un certain temps que welco_url n'est plus posée, même avec welco déployé (#31683, il y a 4 ans); il y aura peut-être quelques endroits qui avaient welco_url, et perdront donc la colonne avec ce patch, si ça arrive, et que quelqu'un s'en rend compte, il y aura juste à cocher la case.
|
||||
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<table id="listing" class="main">')
|
||||
|
@ -1809,8 +1809,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
yield FakeField('id', 'id', _('Number'))
|
||||
if self.formdef.default_digest_template:
|
||||
yield FakeField('digest', 'digest', _('Digest'))
|
||||
if get_publisher().get_site_option('welco_url', 'variables'):
|
||||
yield FakeField('submission_channel', 'submission_channel', _('Channel'))
|
||||
yield FakeField('submission_channel', 'submission_channel', _('Channel'))
|
||||
fpeters
commented
Pour les tableaux de traitement par formulaire, comme il s'agit juste pour le canal de saisie d'être proposé en possiblité de colonne (vs la vue globale où ça ajoute une colonne), ici je décide de tout le temps proposer le choix. Pour les tableaux de traitement par formulaire, comme il s'agit juste pour le canal de saisie d'être proposé en possiblité de colonne (vs la vue globale où ça ajoute une colonne), ici je décide de tout le temps proposer le choix.
|
||||
if self.formdef.backoffice_submission_roles:
|
||||
yield FakeField('submission_agent', 'submission_agent', _('Submission By'))
|
||||
yield FakeField('time', 'time', _('Created'))
|
||||
|
|
Loading…
Reference in New Issue
J'ai hésité entre ça et un écran de paramétrage "Vue globale" (j'étais d'ailleurs parti là-dessus), mais il y a demande pour d'autres paramétrages sur les canaux de saisie (voir https://dev.entrouvert.org/issues/75961) et donc ce choix.
Est-ce qu'on étendrait pas à "submission" ("Saisie backoffice" d'une façon générale) au lieu de juste "submission-channels" ? Dans l'idée qu'on y piloterait un jour d'autres choses en relation avec la saisie backoffice -- ceci étant je suis bien incapable de dire quoi.