|
78 | 78 | headers = {"accept": "*/*", "Content-Type": "application/json"} |
79 | 79 |
|
80 | 80 |
|
81 | | -def preprocess_for_json(d): |
82 | | - """Recursively converts datetime/date objects in a dict to ISO strings.""" |
83 | | - if isinstance(d, dict): |
84 | | - return {k: preprocess_for_json(v) for k, v in d.items()} |
85 | | - elif isinstance(d, list): |
86 | | - return [preprocess_for_json(i) for i in d] |
87 | | - elif isinstance(d, (datetime, date)): |
88 | | - return d.isoformat() |
89 | | - return d |
90 | | - |
91 | | - |
92 | 81 | class ServerConfigDialog(QDialog, Ui_serverDialog): |
93 | 82 | """ |
94 | 83 | Logic for the Server Configuration Dialog. |
@@ -190,7 +179,7 @@ def on_button_clicked(self, button): |
190 | 179 | # check #1: show diff with "Procced" and "Cancel" options |
191 | 180 | if not self._diff_original_and_current_data(): |
192 | 181 | return |
193 | | - |
| 182 | + |
194 | 183 | self.server_config(save=True) |
195 | 184 | else: |
196 | 185 | # check #1: show diff with "Procced" and "Cancel" options |
@@ -236,10 +225,9 @@ def push_to_server(self, url): |
236 | 225 | f"Pushing configuration to: {url}", |
237 | 226 | ) |
238 | 227 |
|
239 | | - config_dict = self.config_data.asdict_enum_safe(self.config_data) |
240 | | - |
241 | | - # Pre-process the dictionary to handle datetime objects |
242 | | - processed_config_dict = preprocess_for_json(config_dict) |
| 228 | + processed_config_dict = self.config_data.asdict_enum_safe( |
| 229 | + self.config_data, datetime_to_str=True |
| 230 | + ) |
243 | 231 |
|
244 | 232 | # TODO: support authentication through the QT framework |
245 | 233 | try: |
|
0 commit comments