All trainees: factor out and improve the queryset
All trainees: factor out and improve the queryset

Changes:
* queryset "generation" is moved to a separate function
* indentation was improved
* is_*_instructor Sum(Case(When)) spaghetti was simplified using
  Python sub-function
* new, general is_instructor annotation was added. Works with all
  instructor badges.

swcarpentry/amy,swcarpentry/amy,pbanaszkiewicz/amy,pbanaszkiewicz/amy,pbanaszkiewicz/amy,swcarpentry/amy