Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/formpack/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def to_json(self, **kwargs):
def export(self, lang=UNSPECIFIED_TRANSLATION, group_sep='/', hierarchy_in_labels=False,
versions=-1, multiple_select="both",
force_index=False, copy_fields=(), title=None,
tag_cols_for_header=None):
tag_cols_for_header=None, lang_header=-1):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tag_cols_for_header=None, lang_header=-1):
header_lang=None,
tag_cols_for_header=None):

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cannot set None to default value for "header_lang" otherwise we cannot know if it is not set or set to None. And, if user call with : (lang=False,header_lang=None) I don't want to change value of arg header_lang. If user call with (lang=False) - header_lang is not set, I want to override header_lang with lang value for not change the current algo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. Thanks for reminding me of this. I will discuss this with the team and see if we can agree on -1 or a different solution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @dorey , do you know if you can agree a -1 value (or a different solution), and also, accept this PR in the futur ?

"""
Create an export for given versions of the form
"""
Expand All @@ -348,7 +348,8 @@ def export(self, lang=UNSPECIFIED_TRANSLATION, group_sep='/', hierarchy_in_label
version_id_keys=self.version_id_keys(versions),
title=title, multiple_select=multiple_select,
force_index=force_index, copy_fields=copy_fields,
tag_cols_for_header=tag_cols_for_header)
tag_cols_for_header=tag_cols_for_header,
lang_header=lang_header)

def autoreport(self, versions=-1):
"""
Expand Down
12 changes: 8 additions & 4 deletions src/formpack/reporting/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, formpack, form_versions, lang=UNSPECIFIED_TRANSLATION,
group_sep="/", hierarchy_in_labels=False,
version_id_keys=[],
multiple_select="both", copy_fields=(), force_index=False,
title="submissions", tag_cols_for_header=None):
title="submissions", tag_cols_for_header=None, lang_header=-1):
"""

:param formpack: FormPack
Expand All @@ -44,10 +44,13 @@ def __init__(self, formpack, form_versions, lang=UNSPECIFIED_TRANSLATION,
:param force_index: bool.
:param title: string
:param tag_cols_for_header: list
:param lang_header: string, False (`constants.UNSPECIFIED_TRANSLATION`), or
None (`constants.UNTRANSLATED`), if not set, default value equal lang arg.
"""

self.formpack = formpack
self.lang = lang
self.lang_header = self.lang if lang_header == -1 else lang_header
self.group_sep = group_sep
self.title = title
self.versions = form_versions
Expand Down Expand Up @@ -76,7 +79,7 @@ def __init__(self, formpack, form_versions, lang=UNSPECIFIED_TRANSLATION,
# this deals with merging all form versions headers and labels
params = (
lang, group_sep, hierarchy_in_labels, multiple_select,
tag_cols_for_header,
tag_cols_for_header, self.lang_header,
)
res = self.get_fields_labels_tags_for_all_versions(*params)
self.sections, self.labels, self.tags = res
Expand Down Expand Up @@ -157,7 +160,8 @@ def get_fields_labels_tags_for_all_versions(self,
group_sep="/",
hierarchy_in_labels=False,
multiple_select="both",
tag_cols_for_header=None):
tag_cols_for_header=None,
lang_header=UNSPECIFIED_TRANSLATION):
""" Return 3 mappings containing field, labels, and tags by section

This is needed because when making an export for several
Expand Down Expand Up @@ -199,7 +203,7 @@ def get_fields_labels_tags_for_all_versions(self,
for field in all_fields:
section_fields.setdefault(field.section.name, []).append(field)
section_labels.setdefault(field.section.name, []).append(
field.get_labels(lang, group_sep,
field.get_labels(lang_header, group_sep,
hierarchy_in_labels,
multiple_select)
)
Expand Down