Last active
November 5, 2015 17:13
-
-
Save samirbr/f6fdd15b0fb9130d1642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def remove_keys(d, keys): | |
| for key in keys: | |
| d.pop(key) | |
| return d | |
| for consistency in Consistency.objects.filter(question__parent_id=form_to_copy.id): | |
| c_dict = generic_as_dict(consistency) | |
| c_dict = remove_keys(c_dict, ['id', 'condition', 'question']) | |
| cond_dict = generic_as_dict(consistency.condition) | |
| condition = Condition( | |
| question_id=controller[consistency.condition.question.id], | |
| lookup=cond_dict['lookup'], | |
| conjunction="or" | |
| ) | |
| condition.save() | |
| new_consistency = Consistency(**c_dict) | |
| new_consistency.question_id = controller[consistency.question.id] | |
| new_consistency.condition = condition | |
| new_consistency.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for denial in Denial.objects.filter(question__parent_id=form_to_copy.id): | |
| d_dict = generic_as_dict(denial) | |
| d_dict = remove_keys(d_dict, ['id', 'question']) | |
| new_denial = Denial(**d_dict) | |
| new_denial.question_id = controller[denial.question.id] | |
| new_denial.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for jump in Jump.objects.filter(question__parent_id=form_to_copy.id): | |
| j_dict = generic_as_dict(jump) | |
| j_dict = remove_keys(j_dict, ['id', 'question', 'target']) | |
| new_jump = Jump(**j_dict) | |
| new_jump.question_id = controller[jump.question.id] | |
| new_jump.target_id = controller[jump.target.id] | |
| new_jump.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment