Skip to content

Commit

Permalink
Add chart_default_filename to class_data_dict, save chart to chart_data.
Browse files Browse the repository at this point in the history
Safe filename form of chart_name used to save chart_data_file and to
save a copy of the chart image in classname/chart_data with it.
Also used to supply a suggested filename to chart save dialogue.

Signed-off-by: David <toonarmycaptain@hotmail.com>
  • Loading branch information
toonarmycaptain committed Dec 19, 2018
1 parent bc930d2 commit 4d86c83
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dionysus_app/chart_generator/create_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ def new_chart():
# - chart/image title options eg name different from displayed title
# - axis labels, scale/axis tick markings

chart_name, class_name, student_scores, chart_params = assemble_chart_data()
chart_name, chart_default_filename, class_name, student_scores, chart_params = assemble_chart_data()

chart_data_dict = {'class_name': class_name,
'chart_default_filename': chart_default_filename,
'chart_name': chart_name,
'chart_params': chart_params,
'score-avatar_dict': student_scores,
Expand All @@ -59,10 +60,12 @@ def assemble_chart_data():

chart_name = take_chart_name()

chart_filename = clean_for_filename(chart_name)

chart_params = set_chart_params()
# chart options here or before score entry, setting chart params, min, max scores etc

return chart_name, class_name, student_scores, chart_params
return chart_name, chart_filename, class_name, student_scores, chart_params


def write_chart_data_to_file(chart_data_dict: dict):
Expand Down Expand Up @@ -94,7 +97,7 @@ def write_chart_data_to_file(chart_data_dict: dict):
"""
file_chart_data_dict = deepcopy(chart_data_dict) # Copy so as to not modify in-use dict.

chart_filename = clean_for_filename(file_chart_data_dict['chart_name'])
chart_filename = file_chart_data_dict['chart_default_filename']
chart_data_file = chart_filename + CHART_DATA_FILE_TYPE
chart_data_filepath = CLASSLIST_DATA_PATH.joinpath(
file_chart_data_dict['class_name'], 'chart_data', chart_data_file)
Expand Down

2 comments on commit 4d86c83

@toonarmycaptain
Copy link
Owner Author

Choose a reason for hiding this comment

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

#88

@toonarmycaptain
Copy link
Owner Author

Choose a reason for hiding this comment

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

#88

Please sign in to comment.