scout/server/utils.py
def institute_and_case(store, institute_id, case_name=None):
    """Fetch insitiute and case objects."""
    institute_obj = store.institute(institute_id)
    if institute_obj is None and institute_id != 'favicon.ico':
        flash("Can't find institute: {}".format(institute_id), 'warning')
        return abort(404)

    if case_name:
        if case_name:
            case_obj = store.case(institute_id=institute_id, display_name=case_name)
            if case_obj is None:
                return abort(404)

    # validate that user has access to the institute
    if not current_user.is_admin:
        if institute_id not in current_user.institutes:
            if not case_name or not any(inst_id in case_obj['collaborators'] for inst_id in
                                        current_user.institutes):
                # you don't have access!!
                flash("You don't have acccess to: {}".format(institute_id),'danger')
                return abort(403)

    # you have access!
    if case_name:
        return institute_obj, case_obj
    else:
        return institute_obj
def institute_and_case(store, institute_id, case_name=None):
    institute_obj = store.institute(institute_id)
    if institute_obj is None and institute_id != 'favicon.ico':
        flash("Can't find institute: {}".format(institute_id), 'warning')
        return abort(404)

    if case_name:
        if case_name:
            case_obj = store.case(institute_id=institute_id, display_name=case_name)
            if case_obj is None:
                return abort(404)

    # validate that user has access to the institute
    if not current_user.is_admin:
        if institute_id not in current_user.institutes:
            if not case_name or not any(inst_id in case_obj['collaborators'] for inst_id in
                                        current_user.institutes):
                # you don't have access!!
                flash("You don't have acccess to: {}".format(institute_id),'danger')
                return abort(403)

    # you have access!
    if case_name:
        return institute_obj, case_obj
    else:
        return institute_obj
def institute_and_case ( store , institute_id , case_name = None ) : institute_obj = store . institute ( institute_id ) if institute_obj is None and institute_id != 'favicon.ico' : flash ( "Can't find institute: {}" . format ( institute_id ) , 'warning' ) return abort ( 404 ) if case_name : if case_name : case_obj = store . case ( institute_id = institute_id , display_name = case_name ) if case_obj is None : return abort ( 404 ) # validate that user has access to the institute if not current_user . is_admin : if institute_id not in current_user . institutes : if not case_name or not any ( inst_id in case_obj [ 'collaborators' ] for inst_id in current_user . institutes ) : # you don't have access!! flash ( "You don't have acccess to: {}" . format ( institute_id ) , 'danger' ) return abort ( 403 ) # you have access! if case_name : return institute_obj , case_obj else : return institute_obj
Fetch insitiute and case objects.
Fetch insitiute and case objects .