|
23 | 23 |
|
24 | 24 | class FormPack(object): |
25 | 25 |
|
26 | | - |
27 | 26 | def __init__(self, versions=None, title='Submissions', id_string=None, |
28 | 27 | default_version_id_key='__version__', |
29 | 28 | strict_schema=False, |
@@ -193,19 +192,24 @@ def summr(v): |
193 | 192 |
|
194 | 193 | @staticmethod |
195 | 194 | def _combine_field_choices(old_field, new_field): |
196 | | - """ Update `new_field.choice` so that it contains everything from |
197 | | - `old_field.choice`. In the event of a conflict, `new_field.choice` |
198 | | - wins. If either field does not have a `choice` attribute, do |
199 | | - nothing |
| 195 | + """ |
| 196 | + Update `new_field.choice` so that it contains everything from |
| 197 | + `old_field.choice`. In the event of a conflict, `new_field.choice` |
| 198 | + wins. If either field does not have a `choice` attribute, do |
| 199 | + nothing |
| 200 | +
|
| 201 | + :param old_field: FormField |
| 202 | + :param new_field: FormField |
| 203 | + :return: FormField. Updated new_field |
200 | 204 | """ |
201 | 205 | try: |
202 | 206 | old_choice = old_field.choice |
203 | 207 | new_choice = new_field.choice |
| 208 | + new_field.merge_choice(old_choice) |
204 | 209 | except AttributeError: |
205 | | - return |
206 | | - combined_options = old_choice.options.copy() |
207 | | - combined_options.update(new_choice.options) |
208 | | - new_choice.options = combined_options |
| 210 | + pass |
| 211 | + |
| 212 | + return new_field |
209 | 213 |
|
210 | 214 | def get_fields_for_versions(self, versions=-1, data_types=None): |
211 | 215 |
|
@@ -274,7 +278,9 @@ def get_fields_for_versions(self, versions=-1, data_types=None): |
274 | 278 | # Because versions_desc are ordered from latest to oldest, |
275 | 279 | # we use current field object as the old one and the one already |
276 | 280 | # in position as the latest one. |
277 | | - self._combine_field_choices(field_object, latest_field_object) |
| 281 | + new_object = self._combine_field_choices( |
| 282 | + field_object, latest_field_object) |
| 283 | + tmp2d[position[0]][position[1]] = new_object |
278 | 284 | else: |
279 | 285 | try: |
280 | 286 | current_index_list = tmp2d[index] |
|
0 commit comments