Skip to content

Commit

Permalink
Auto assign name for generated report (taking from template name, e.g…
Browse files Browse the repository at this point in the history
…. 2_start_list.html - 20210521_start_list.html) (#394)
  • Loading branch information
sergeikobelev authored May 21, 2021
1 parent 24e1c3b commit ec4444e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sportorg/gui/dialogs/report_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ def apply_changes_impl(self):

races_dict = [r.to_dict() for r in races()]

template_path_items = template_path.split('/')[-1]
template_path_items = '.'.join(template_path_items.split('.')[:-1]).split('_')

# remove tokens, containing only digits
for i in template_path_items:
if str(i).isdigit():
template_path_items.remove(i)
report_suffix = '_'.join(template_path_items)

if template_path.endswith('.docx'):
# DOCX template processing
full_path = config.template_dir() + template_path
Expand All @@ -162,8 +171,8 @@ def apply_changes_impl(self):
file_name = get_save_file_name(
translate('Save As MS Word file'),
translate('MS Word file (*.docx)'),
'{}_official'.format(
obj.data.get_start_datetime().strftime('%Y%m%d')
'{}_{}'.format(
obj.data.get_start_datetime().strftime('%Y%m%d'), report_suffix
),
)
if file_name:
Expand All @@ -186,8 +195,8 @@ def apply_changes_impl(self):
file_name = get_save_file_name(
translate('Save As HTML file'),
translate('HTML file (*.html)'),
'{}_report'.format(
obj.data.get_start_datetime().strftime('%Y%m%d')
'{}_{}'.format(
obj.data.get_start_datetime().strftime('%Y%m%d'), report_suffix
),
)
if len(file_name):
Expand Down

0 comments on commit ec4444e

Please sign in to comment.