Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct field ordering -- https://github.com/ispras/lingvodoc-react/issues/1109 #1499

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions lingvodoc/scripts/desktop_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ def update_perspective_fields(req, perspective_client_id, perspective_object_id,
SyncDBSession.delete(field)
position = 1
for field in req:
create_nested_field(field=field,
perspective=perspective,
client_id=client.id,
upper_level=None,
link_ids=link_ids, position=position)
position += 1
position = (
create_nested_field(field=field,
perspective=perspective,
client_id=client.id,
upper_level=None,
link_ids=link_ids,
position=position)
)

return response
else:
Expand All @@ -162,19 +164,22 @@ def create_nested_field(field, perspective, client_id, upper_level, link_ids, po
if field.get('link'):
field_object.link_client_id = field['link']['client_id']
field_object.link_object_id = field['link']['object_id']

SyncDBSession.flush()
contains = field.get('contains', None)
if contains:
inner_position = 1
for subfield in contains:
position += 1

contains = field.get('contains', None) or []
for subfield in contains:
position = (
create_nested_field(subfield,
perspective,
client_id,
upper_level=field_object,
link_ids=link_ids,
position=inner_position)
inner_position += 1
return
position=position)
)

return position


def object_file_path(obj, base_path, filename, create_dir=False):
Expand Down
35 changes: 21 additions & 14 deletions lingvodoc/scripts/dictionary_dialeqt_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,22 @@ def create_nested_field(field, perspective, client_id, upper_level, link_ids, po
if field.get('link'):
field_object.link_client_id = field['link']['client_id']
field_object.link_object_id = field['link']['object_id']

DBSession.flush()
contains = field.get('contains', None)
if contains:
inner_position = 1
for subfield in contains:
position += 1

contains = field.get('contains', None) or []
for subfield in contains:
position = (
create_nested_field(subfield,
perspective,
client_id,
upper_level=field_object,
link_ids=link_ids,
position=inner_position)
inner_position += 1
return
position=position)
)

return position


def update_perspective_fields(req, perspective_client_id, perspective_object_id, client):
Expand Down Expand Up @@ -262,15 +265,19 @@ def update_perspective_fields(req, perspective_client_id, perspective_object_id,
DBSession.flush()
#for field in fields:
# DBSession.delete(field)
if not int(len(fields)):

if len(fields) == 0:
position = 1
for field in req:
create_nested_field(field=field,
perspective=perspective,
client_id=client.id,
upper_level=None,
link_ids=link_ids, position=position)
position += 1
position = (
create_nested_field(field=field,
perspective=perspective,
client_id=client.id,
upper_level=None,
link_ids=link_ids,
position=position)
)

return response
else:
return {'error': str("No such perspective in the system")}
Expand Down
87 changes: 51 additions & 36 deletions lingvodoc/utils/corpus_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,23 @@ def create_nested_field(
field.link_object_id = link_info['object_id']

DBSession.add(field)
position += 1

contains = field_info.get('contains')

if contains is not None:

for sub_position, sub_field_info in enumerate(contains, 1):

create_nested_field(
sub_field_info,
perspective,
client,
upper_level = field,
position = sub_position)
for sub_field_info in contains:
position = (
create_nested_field(
sub_field_info,
perspective,
client,
upper_level = field,
position = position)
)

return position

def object_file_path(entity_dict, base_path, folder_name, filename):

Expand Down Expand Up @@ -971,13 +974,16 @@ def add_perspective(pesponse):
"client_id": get_field_id(fieldname)[0],
"object_id": get_field_id(fieldname)[1]})

for position, field_info in enumerate(field_info_list, 1):
create_nested_field(
field_info,
le_perspective,
extra_client,
None,
position)
position = 1
for field_info in field_info_list:
position = (
create_nested_field(
field_info,
le_perspective,
extra_client,
None,
position)
)

# Creating fields of the second perspective, if required.

Expand Down Expand Up @@ -1012,13 +1018,16 @@ def add_perspective(pesponse):
"client_id": get_field_id(fieldname)[0],
"object_id": get_field_id(fieldname)[1]})

for position, field_info in enumerate(field_info_list, 1):
create_nested_field(
field_info,
pa_perspective,
extra_client,
None,
position)
position = 1
for field_info in field_info_list:
position = (
create_nested_field(
field_info,
pa_perspective,
extra_client,
None,
position)
)

# Creating fields of the third perspective, if required.

Expand All @@ -1044,13 +1053,16 @@ def add_perspective(pesponse):
"client_id": get_field_id(fieldname)[0],
"object_id": get_field_id(fieldname)[1]})

for position, field_info in enumerate(field_info_list, 1):
create_nested_field(
field_info,
mo_perspective,
extra_client,
None,
position)
position = 1
for field_info in field_info_list:
position = (
create_nested_field(
field_info,
mo_perspective,
extra_client,
None,
position)
)

# Creating fields of the fourth perspective, if required.

Expand All @@ -1074,13 +1086,16 @@ def add_perspective(pesponse):
"client_id": get_field_id(fieldname)[0],
"object_id": get_field_id(fieldname)[1]})

for position, field_info in enumerate(field_info_list, 1):
create_nested_field(
field_info,
mp_perspective,
extra_client,
None,
position)
position = 1
for field_info in field_info_list:
position = (
create_nested_field(
field_info,
mp_perspective,
extra_client,
None,
position)
)

# Getting field data types.

Expand Down