Drainage of viscous gravity currents from the edge of a porous or fractured domain with variable properties