remove duplicated code in provider/views.py