Refactored code / removed a lot of unrelated code from views file in django app