sql: expose backoffice_submission into views (#9767)
This commit is contained in:
parent
f683f27fe1
commit
f1e59b2bc3
|
@ -47,6 +47,8 @@ réservé aux usages internes.
|
|||
<item><p><var>category_id</var> : identifiant de la catégorie</p></item>
|
||||
<item><p><var>formdef_id</var> : identifiant du type de formulaire</p></item>
|
||||
<item><p><var>fts</var> : indexation texte intégral</p></item>
|
||||
<item><p><var>backoffice_submission</var> : indicateur de saisie backoffice</p></item>
|
||||
<item><p><var>submission_channel</var> : canal d'entrée</p></item>
|
||||
</list>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -1301,3 +1301,32 @@ def test_select_formdata_after_formdef_removal():
|
|||
|
||||
objects = sql.AnyFormData.select()
|
||||
assert len(objects) == 1
|
||||
|
||||
@postgresql
|
||||
def test_views_submission_info():
|
||||
drop_formdef_tables()
|
||||
conn, cur = sql.get_connection_and_cursor()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'test backoffice submission'
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
|
||||
data_class = formdef.data_class(mode='sql')
|
||||
formdata1 = data_class()
|
||||
formdata1.submission_channel = 'mail'
|
||||
formdata1.backoffice_submission = True
|
||||
formdata1.store()
|
||||
|
||||
formdata2 = data_class()
|
||||
formdata2.backoffice_submission = False
|
||||
formdata2.store()
|
||||
|
||||
cur.execute('''SELECT COUNT(*) FROM wcs_all_forms WHERE backoffice_submission IS TRUE''')
|
||||
assert bool(cur.fetchone()[0] == 1)
|
||||
|
||||
cur.execute('''SELECT COUNT(*) FROM wcs_all_forms WHERE backoffice_submission IS FALSE''')
|
||||
assert bool(cur.fetchone()[0] == 1)
|
||||
|
||||
cur.execute('''SELECT COUNT(*) FROM wcs_all_forms WHERE submission_channel = %s''', ('mail',))
|
||||
assert bool(cur.fetchone()[0] == 1)
|
||||
|
|
|
@ -560,7 +560,7 @@ def get_view_fields(formdef):
|
|||
view_fields.append(("int '%s'" % (formdef.category_id or 0), 'category_id'))
|
||||
view_fields.append(("int '%s'" % (formdef.id or 0), 'formdef_id'))
|
||||
for field in ('id', 'user_id', 'user_hash', 'receipt_time', 'status',
|
||||
'id_display', 'submission_channel'):
|
||||
'id_display', 'submission_channel', 'backoffice_submission'):
|
||||
view_fields.append((field, field))
|
||||
return view_fields
|
||||
|
||||
|
@ -1745,7 +1745,7 @@ def get_yearly_totals(period_start=None, period_end=None, criterias=None):
|
|||
return result
|
||||
|
||||
|
||||
SQL_LEVEL = 12
|
||||
SQL_LEVEL = 13
|
||||
|
||||
def migrate_global_views(conn, cur):
|
||||
cur.execute('''SELECT COUNT(*) FROM information_schema.tables
|
||||
|
@ -1779,14 +1779,15 @@ def migrate():
|
|||
raise RuntimeError()
|
||||
if sql_level < 1: # 1: introduction of tracking_code table
|
||||
do_tracking_code_table()
|
||||
if sql_level < 11:
|
||||
if sql_level < 13:
|
||||
# 2: introduction of formdef_id in views
|
||||
# 5: add concerned_roles_array, is_at_endpoint and fts to views
|
||||
# 7: add backoffice_submission to tables and views
|
||||
# 7: add backoffice_submission to tables
|
||||
# 8: add submission_context to tables
|
||||
# 9: add last_update_time to views
|
||||
# 10: add submission_channel to tables
|
||||
# 11: add formdef_name and user_name to views
|
||||
# 13: add backoffice_submission to views
|
||||
migrate_views(conn, cur)
|
||||
if sql_level < 12:
|
||||
# 3: introduction of _structured for user fields
|
||||
|
|
Loading…
Reference in New Issue