(request, domain, app_id, module_unique_id)
return back_to_main(
        request, domain,
        app_id=app.id,
        module_unique_id=module.unique_id,
        form_unique_id=form.unique_id
    )
Adds a form to an app (under a module)
Adds a form to an app (under a module)
Adds a form to an app ( under a module )
def new_form(request, domain, app_id, module_unique_id):
    """
    Adds a form to an app (under a module)
    """
    app = get_app(domain, app_id)

    try:
        module = app.get_module_by_unique_id(module_unique_id)
    except ModuleNotFoundException:
        raise HttpResponseBadRequest

    lang = request.COOKIES.get('lang', app.langs[0])
    form_type = request.POST.get('form_type', 'form')
    case_action = request.POST.get('case_action', 'none')

    if case_action == 'open':
        name = _('Register')
    elif case_action == 'update':
        name = _('Followup')
    elif module.is_training_module:
        name = _('Lesson')
    else:
        name = _('Survey')

    if form_type == "shadow":
        if module.module_type == "advanced":
            form = module.new_shadow_form(name, lang)
        else:
            raise Exception("Shadow forms may only be created under shadow modules")
    else:
        form = module.new_form(name, lang)

    if form_type != "shadow":
        if case_action == 'update':
            form.requires = 'case'
            form.actions.update_case = UpdateCaseAction(
                condition=FormActionCondition(type='always'))
        elif case_action == 'open':
            form.actions.open_case = OpenCaseAction(
                condition=FormActionCondition(type='always'))
            form.actions.update_case = UpdateCaseAction(
                condition=FormActionCondition(type='always'))

    app.save()
    return back_to_main(
        request, domain,
        app_id=app.id,
        module_unique_id=module.unique_id,
        form_unique_id=form.unique_id
    )
def new_form ( request , domain , app_id , module_unique_id ) : app = get_app ( domain , app_id ) try : module = app . get_module_by_unique_id ( module_unique_id ) except ModuleNotFoundException : raise HttpResponseBadRequest lang = request . COOKIES . get ( 'lang' , app . langs [ 0 ] ) form_type = request . POST . get ( 'form_type' , 'form' ) case_action = request . POST . get ( 'case_action' , 'none' ) if case_action == 'open' : name = _ ( 'Register' ) elif case_action == 'update' : name = _ ( 'Followup' ) elif module . is_training_module : name = _ ( 'Lesson' ) else : name = _ ( 'Survey' ) if form_type == "shadow" : if module . module_type == "advanced" : form = module . new_shadow_form ( name , lang ) else : raise Exception ( "Shadow forms may only be created under shadow modules" ) else : form = module . new_form ( name , lang ) if form_type != "shadow" : if case_action == 'update' : form . requires = 'case' form . actions . update_case = UpdateCaseAction ( condition = FormActionCondition ( type = 'always' ) ) elif case_action == 'open' : form . actions . open_case = OpenCaseAction ( condition = FormActionCondition ( type = 'always' ) ) form . actions . update_case = UpdateCaseAction ( condition = FormActionCondition ( type = 'always' ) ) app . save ( ) return back_to_main ( request , domain , app_id = app . id , module_unique_id = module . unique_id , form_unique_id = form . unique_id )