authentication/admin_authentication.py
def assert_researcher_under_admin(researcher, study=None):
    """ Asserts that the researcher provided is allowed to be edited by the session user.
        If study is provided then the admin test is strictly for that study, otherwise it checks
        for admin status anywhere. """
    session_researcher = get_session_researcher()
    if session_researcher.site_admin:
        return

    if researcher.site_admin:
        flash("This user is a site administrator, action rejected.", "danger")
        return abort(403)

    kwargs = dict(relationship=ResearcherRole.study_admin)
    if study is not None:
        kwargs['study'] = study

    if researcher.study_relations.filter(**kwargs).exists():
        flash("This user is a study administrator, action rejected.", "danger")
        return abort(403)

    session_studies = set(session_researcher.get_admin_study_relations().values_list("study_id", flat=True))
    researcher_studies = set(researcher.get_researcher_study_relations().values_list("study_id", flat=True))

    if not session_studies.intersection(researcher_studies):
        flash("You are not an administrator for that researcher, action rejected.", "danger")
        return abort(403)
 Asserts that the researcher provided is allowed to be edited by the session user.
        If study is provided then the admin test is strictly for that study, otherwise it checks
        for admin status anywhere. 
Asserts that the researcher provided is allowed to be edited by the session user.
If study is provided then the admin test is strictly for that study, otherwise it checks
for admin status anywhere.
Asserts that the researcher provided is allowed to be edited by the session user . If study is provided then the admin test is strictly for that study otherwise it checks for admin status anywhere .
def assert_researcher_under_admin(researcher, study=None):
    session_researcher = get_session_researcher()
    if session_researcher.site_admin:
        return
    if researcher.site_admin:
        flash("This user is a site administrator, action rejected.", "danger")
        return abort(403)
    kwargs = dict(relationship=ResearcherRole.study_admin)
    if study is not None:
        kwargs['study'] = study
    if researcher.study_relations.filter(**kwargs).exists():
        flash("This user is a study administrator, action rejected.", "danger")
        return abort(403)
    session_studies = set(session_researcher.get_admin_study_relations().values_list("study_id", flat=True))
    researcher_studies = set(researcher.get_researcher_study_relations().values_list("study_id", flat=True))
    if not session_studies.intersection(researcher_studies):
        flash("You are not an administrator for that researcher, action rejected.", "danger")
        return abort(403)
def assert_researcher_under_admin ( researcher , study = None ) : session_researcher = get_session_researcher ( ) if session_researcher . site_admin : return if researcher . site_admin : flash ( "This user is a site administrator, action rejected." , "danger" ) return abort ( 403 ) kwargs = dict ( relationship = ResearcherRole . study_admin ) if study is not None : kwargs [ 'study' ] = study if researcher . study_relations . filter ( ** kwargs ) . exists ( ) : flash ( "This user is a study administrator, action rejected." , "danger" ) return abort ( 403 ) session_studies = set ( session_researcher . get_admin_study_relations ( ) . values_list ( "study_id" , flat = True ) ) researcher_studies = set ( researcher . get_researcher_study_relations ( ) . values_list ( "study_id" , flat = True ) ) if not session_studies . intersection ( researcher_studies ) : flash ( "You are not an administrator for that researcher, action rejected." , "danger" ) return abort ( 403 )
Asserts that the researcher provided is allowed to be edited by the session user.
Asserts that the researcher provided is allowed to be edited by the session user .
""" Asserts that the researcher provided is allowed to be edited by the session user.
        If study is provided then the admin test is strictly for that study, otherwise it checks
        for admin status anywhere. """
researcher
study