-
Notifications
You must be signed in to change notification settings - Fork 12
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
RDISCROWD-7364 custom task export fields #988
Conversation
Pull Request Test Coverage Report for Build 11600690507Details
💛 - Coveralls |
pybossa/exporter/export_helpers.py
Outdated
new_headers = [] | ||
accepted_task_info_fields_set = set(accepted_task_info_fields) | ||
for header in headers: | ||
if header == 'task__info': | ||
pass | ||
elif header.startswith('task__info__'): | ||
masked_header = header[12: ] | ||
if masked_header in accepted_task_info_fields_set: | ||
new_headers.append(header) | ||
else: | ||
new_headers.append(header) | ||
return new_headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmetic; indentation to be corrected here
pybossa/exporter/export_helpers.py
Outdated
if header == 'task__info': | ||
pass | ||
elif header.startswith('task__info__'): | ||
masked_header = header[12: ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For code clarity, we can add a variable for number here
pybossa/exporter/export_helpers.py
Outdated
def filter_table_headers(headers, accepted_task_info_fields): | ||
new_headers = [] | ||
accepted_task_info_fields_set = set(accepted_task_info_fields) | ||
for header in headers: | ||
if header == 'task__info': | ||
pass | ||
elif header.startswith('task__info__'): | ||
masked_header = header[12: ] | ||
if masked_header in accepted_task_info_fields_set: | ||
new_headers.append(header) | ||
else: | ||
new_headers.append(header) | ||
return new_headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if following changes makes sense considering comments mentioned above
def filter_table_headers(headers, filtered_columns):
accepted_task_info_fields = set(filtered_columns) if filtered_columns else set()
task_info_header = "task__info__"
task_info_header_len = len(task_info_header)
for header in headers:
if header != 'task__info':
if header.startswith(task_info_header):
masked_header = header[task_info_header_len:]
if masked_header in accepted_task_info_fields:
new_headers.append(header)
else:
new_headers.append(header)
pybossa/exporter/export_helpers.py
Outdated
if header == 'task__info': | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass can be avoided w/ flipping the condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we switch to
if header != 'task__info':
...
else:
new_headers.append(header)
task__info
will always get added to new_headers
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, there are 3 cases for each header:
- header = 'task__info', so we skip it
- header is like 'task__info__[fieldname], so we check fieldname against accepted fields set and add accordingly
- header is something else, so we add it to the new_headers list (task__id, task__state, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely due to small tab space, it was not clear that else part of if header != 'task__info':
won't be adding new_header
always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon making this changes, PR can be merged. Thanks!
Issue number of the reported bug or feature request: RDISCROWD-7364
Describe your changes
display_info_columns
is in the request body, filter thetask__info
fields to only contain fields indisplay_info_columns
.Testing performed
tested locally