示例#1
0
def get_report_text(userid, qu_id, download_info):
    is_admin = User.__is_admin(userid)
    if not is_admin:
        qu = User.get_qu(userid, qu_id) or {}
        info = qu.get('info') or {}
        if info.get('auth') != 2:
            return None
    report_type = download_info.get('type')
    if not report_type:
        return None
    res = Questionnair.get_qu(qu_id, ['qu_report_map'])
    report_text = res.get('qu_report_map') or {}
    report_text = report_text.get(report_type)
    return report_text
示例#2
0
def download_report(userid, qu_id, download_info):
    is_admin = User.__is_admin(userid)
    if not is_admin:
        qu = User.get_qu(userid, qu_id) or {}
        info = qu.get('info') or {}
        if info.get('auth') != 2:
            return None
    report_type = download_info.get('type')
    if not report_type:
        return None
    try:
        report_file = send_from_directory('../' + config.RESOURCE_PATH +
                                          'report/mbti/',
                                          report_type + '.pdf',
                                          as_attachment=True)
    except:
        return None
    return report_file