Don't duplicate membership deletion logic

Rather than duplicating the same code for deleting memberships in the
person and organization apps, move the shared code into the generic
document app.

This also has the added benefit of waiting until the existing
memberships have been deleted before calling 'next', which didn't happen
previously so presumably could have caused some issues.

There is still some duplicated logic in the person and organization
apps, but I'm leaving it as it is for now on the assumption that a lot
of this will change when we start powering the UI directly from the API.