some views.py refactoring