def METHOD_NAME(
    request, codelist, codelist_form, reference_formset, signoff_formset, owner_choices
):
    references = [
        {"url": reference["url"], "text": reference["text"]}
        for reference in reference_formset.cleaned_data
        if reference and not reference["DELETE"]
    ]
    signoffs = [
        {"user": signoff["user"], "date": signoff["date"]}
        for signoff in signoff_formset.cleaned_data
        if signoff and not signoff["DELETE"]
    ]
    if owner_choices:
        owner = codelist_form.cleaned_data["owner"]
    else:
        owner = codelist.owner
    try:
        actions.update_codelist(
            codelist=codelist,
            owner=owner,
            name=codelist_form.cleaned_data["name"],
            slug=codelist_form.cleaned_data["slug"],
            description=codelist_form.cleaned_data["description"],
            methodology=codelist_form.cleaned_data["methodology"],
            references=references,
            signoffs=signoffs,
        )
    except actions.DuplicateHandleError as e:
        codelist_form.add_error(e.field, f"Duplicate {e.field}")
        return handle_invalid(
            request, codelist_form, reference_formset, signoff_formset, owner_choices
        )
    return redirect(codelist)