Fix bug #2517 (Replace function-based generic views)

Part of the work was done by dropping external code from Pootle codebase, so this is a huge win.

I am surprised that it took quite a few work.