def delete(request, role_id):

    role = get_object_or_404(ProjectRole, pk=role_id)
    project = role.project
    
    # require permission to proceed
    must_have_permission(request.user, project, "can_edit_roles")

    if role.name == "owner" or role.name == "researcher":
        return simple.direct_to_template(
            request,
            template=TEMPLATE_PATH+"/delete_default.html",
            extra_context={"role": role})
    
    if request.method == "POST":
        role.delete()
        return HttpResponseRedirect(
            reverse("project_detail", args=[project.id]))
    
    return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH+"/delete.html",
        extra_context={
            "breadcrumbs": (
                ("Home", reverse("home")),
                ("Project %s" % role.project.name,
                 reverse("project_detail", args=[role.project.id])),
                ("Delete Role %s" % role.name, request.path),
            ),
            "role": role},
    )
Delete a role
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/roles/views.py/delete