Esempio n. 1
0
def copy_designer_action(draft, slug):
    """Copies the DesignerAction with the given slug."""
    action = get_designer_action(draft, slug)
    action_type = action.type
    if action_type == 'activity':
        obj = DesignerActivity()
    elif action_type == 'commitment':
        obj = DesignerCommitment()
    elif action_type == 'event':
        obj = DesignerEvent()
    _copy_fields(action, obj)
    copy_slug = __get_next_designer_copy_slug(draft, slug)
    obj.slug = copy_slug
    obj.pk = None
    obj.id = None
    obj.save()
    # Copy all the DesignerTextPropmtQuestions
    for question in DesignerTextPromptQuestion.objects.filter(action=action, draft=draft):
        des_obj = DesignerTextPromptQuestion()
        _copy_fields_no_foriegn_keys(question, des_obj)
        des_obj.action = obj
        des_obj.draft = draft
        des_obj.save()

    return obj
Esempio n. 2
0
def copy_designer_action(draft, slug):
    """Copies the DesignerAction with the given slug."""
    action = get_designer_action(draft, slug)
    action_type = action.type
    if action_type == 'activity':
        obj = DesignerActivity()
    elif action_type == 'commitment':
        obj = DesignerCommitment()
    elif action_type == 'event':
        obj = DesignerEvent()
    _copy_fields(action, obj)
    copy_slug = __get_next_designer_copy_slug(draft, slug)
    obj.slug = copy_slug
    obj.pk = None
    obj.id = None
    obj.save()
    # Copy all the DesignerTextPropmtQuestions
    for question in DesignerTextPromptQuestion.objects.filter(action=action, draft=draft):
        des_obj = DesignerTextPromptQuestion()
        _copy_fields_no_foriegn_keys(question, des_obj)
        des_obj.action = obj
        des_obj.draft = draft
        des_obj.save()

    return obj