ajustements à misc.simplify (#21227) #855
|
@ -296,7 +296,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
datasource1 = NamedDataSource.get(4 + 1)
|
||||
datasource2 = NamedDataSource.get(4 + 2)
|
||||
assert datasource1.name == 'Events A'
|
||||
assert datasource1.slug == 'chrono_ds_sluga'
|
||||
assert datasource1.slug == 'chrono_ds_slug_a'
|
||||
|
||||
assert datasource1.external == 'agenda'
|
||||
assert datasource1.external_status is None
|
||||
assert datasource1.data_source == {
|
||||
|
@ -304,7 +304,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
'value': '{{ agendas_url }}api/agenda/events-A/datetimes/',
|
||||
}
|
||||
assert datasource2.name == 'Events B'
|
||||
assert datasource2.slug == 'chrono_ds_slugb'
|
||||
assert datasource2.slug == 'chrono_ds_slug_b'
|
||||
assert datasource2.external == 'agenda'
|
||||
assert datasource2.external_status is None
|
||||
assert datasource2.data_source == {
|
||||
|
@ -377,7 +377,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
'value': '{{ agendas_url }}api/agenda/events-B/datetimes/',
|
||||
}
|
||||
assert datasource3.name == 'Events A'
|
||||
assert datasource3.slug == 'chrono_ds_sluga'
|
||||
assert datasource3.slug == 'chrono_ds_slug_a'
|
||||
assert datasource3.external == 'agenda'
|
||||
assert datasource3.external_status == 'not-found'
|
||||
assert datasource3.data_source == {
|
||||
|
@ -385,7 +385,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
'value': '{{ agendas_url }}api/agenda/events-FOOBAR/datetimes/',
|
||||
}
|
||||
assert datasource4.name == 'Events A'
|
||||
assert datasource4.slug == 'chrono_ds_sluga_1'
|
||||
assert datasource4.slug == 'chrono_ds_slug_a_1'
|
||||
assert datasource4.external == 'agenda'
|
||||
assert datasource4.external_status is None
|
||||
assert datasource4.data_source == {
|
||||
|
@ -422,7 +422,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
build_agenda_datasources(pub)
|
||||
assert NamedDataSource.count() == 4 + 4
|
||||
datasource5 = NamedDataSource.get(4 + 5)
|
||||
assert datasource5.slug == 'chrono_ds_agendameetingsmeetingsamtdynamic'
|
||||
assert datasource5.slug == 'chrono_ds_agenda_meetings_meetings_a_mtdynamic'
|
||||
assert datasource5.data_source == {
|
||||
'type': 'json',
|
||||
'value': '{{ agendas_url }}api/agenda/meetings-A/meetings/{{ form_var_meeting_type_raw }}/datetimes/',
|
||||
|
@ -434,7 +434,7 @@ def test_build_agenda_datasources(mock_collect, pub, chrono_url):
|
|||
build_agenda_datasources(pub)
|
||||
assert NamedDataSource.count() == 4 + 4
|
||||
datasource5 = NamedDataSource.get(4 + 5)
|
||||
assert datasource5.slug == 'chrono_ds_agendameetingsmeetingsamtdynamic'
|
||||
assert datasource5.slug == 'chrono_ds_agenda_meetings_meetings_a_mtdynamic'
|
||||
assert datasource5.data_source == {
|
||||
'type': 'json',
|
||||
'value': '{{ agendas_url }}api/agenda/meetings-A/meetings/{{ form_var_meeting_type_raw }}/datetimes/',
|
||||
|
|
|
@ -159,6 +159,12 @@ def test_simplify_apostrophes():
|
|||
assert simplify('test\'\'\'again') == 'test-again'
|
||||
|
||||
|
||||
def test_simplify_dashes_and_underscores():
|
||||
assert simplify('8100-03_PT') == '8100-03-pt'
|
||||
assert simplify('8100-03_PT', ' ') == '8100 03 pt'
|
||||
assert simplify('8100-03_PT', '_') == '8100_03_pt'
|
||||
|
||||
|
||||
def test_simplify_accented():
|
||||
assert simplify('cliché') == 'cliche'
|
||||
|
||||
|
@ -173,6 +179,10 @@ def test_simplify_mix():
|
|||
assert simplify(' À "cliché"; again? ') == 'a-cliche-again'
|
||||
|
||||
|
||||
def test_simplify_prefix_suffix():
|
||||
assert simplify('-hello world ') == 'hello-world'
|
||||
|
||||
|
||||
def test_json_str_decoder():
|
||||
json_str = json.dumps({'lst': [{'a': 'b'}, 1, 2], 'bla': 'éléphant'})
|
||||
|
||||
|
|
|
@ -178,8 +178,8 @@ def simplify(s, space='-'):
|
|||
else:
|
||||
s = force_str('%s' % s, 'iso-8859-1', errors='ignore')
|
||||
s = unidecode.unidecode(s)
|
||||
s = re.sub(r'[^\w\s\'%s]' % space, '', s).strip().lower()
|
||||
s = re.sub(r'[\s\'%s]+' % space, space, s)
|
||||
s = re.sub(r'[^\w\s\'\-%s]' % space, '', s).strip().lower()
|
||||
s = re.sub(r'[\s\'\-_%s]+' % space, space, s).strip(space)
|
||||
return s
|
||||
|
||||
|
||||
|
|
|
@ -5048,7 +5048,7 @@ def get_period_total(
|
|||
# latest migration, number + description (description is not used
|
||||
# programmaticaly but will make sure git conflicts if two migrations are
|
||||
# separately added with the same number)
|
||||
SQL_LEVEL = (95, 'add a searchable_formdefs table')
|
||||
SQL_LEVEL = (96, 'change to fts normalization')
|
||||
|
||||
|
||||
def migrate_global_views(conn, cur):
|
||||
|
@ -5286,7 +5286,7 @@ def migrate():
|
|||
# 61: use setweight on formdata & user indexation
|
||||
# 62: use setweight on formdata & user indexation (reapply)
|
||||
set_reindex('user', 'needed', conn=conn, cur=cur)
|
||||
if sql_level < 62:
|
||||
if sql_level < 96:
|
||||
# 17: store last_update_time in tables
|
||||
# 18: add user name to full-text search index
|
||||
# 21: (third part), add user ascii_names to full-text index
|
||||
|
@ -5300,6 +5300,7 @@ def migrate():
|
|||
# 55: update full text normalisation (switch to unidecode)
|
||||
# 61: use setweight on formdata & user indexation
|
||||
# 62: use setweight on formdata & user indexation (reapply)
|
||||
# 96: change to fts normalization
|
||||
set_reindex('formdata', 'needed', conn=conn, cur=cur)
|
||||
if sql_level < 74:
|
||||
# 24: add index on evolution(formdata_id)
|
||||
|
|
|
@ -58,7 +58,7 @@ class WorkflowTriggeredEvolutionPart(EvolutionPart):
|
|||
self.content = content
|
||||
self.kind = kind
|
||||
self.datetime = now()
|
||||
self.trigger_name_key = misc.simplify(self.trigger_name.replace('-', '_'), space='_')
|
||||
self.trigger_name_key = misc.simplify(self.trigger_name, space='_')
|
||||
|
||||
|
||||
def jump_and_perform(formdata, action, workflow_data=None):
|
||||
|
|
Loading…
Reference in New Issue
Il peut y avoir changement sur les sources de données issues de chrono mais la mise à jour se base sur l'URL, pas sur le slug, donc pas de problème.