def get_administerable_researchers(): """ Site admins see all researchers, study admins see researchers on their studies. """ researcher_admin = get_session_researcher() if researcher_admin.site_admin: relevant_researchers = Researcher.get_all_researchers_by_username() else: relevant_researchers = researcher_admin.get_administered_researchers_by_username() return relevant_researchers
def edit_study(study_id=None): study = Study.objects.get(pk=study_id) all_researchers = Researcher.get_all_researchers_by_username() return render_template( 'edit_study.html', study=study, all_researchers=all_researchers, allowed_studies=get_admins_allowed_studies(), system_admin=admin_is_system_admin(), redirect_url='/edit_study/{:s}'.format(study_id), )
def manage_researchers(): researcher_list = [] for researcher in Researcher.get_all_researchers_by_username(): allowed_studies = Study.get_all_studies_by_name().filter(researchers=researcher).values_list('name', flat=True) researcher_list.append((researcher.as_native_python(), list(allowed_studies))) return render_template( 'manage_researchers.html', admins=json.dumps(researcher_list), allowed_studies=get_admins_allowed_studies(), system_admin=admin_is_system_admin() )