diff --git a/app.py b/app.py index 0db7352..a9374f7 100644 --- a/app.py +++ b/app.py @@ -305,6 +305,8 @@ def solar(text): show_upload_form = True contract_school = portal.solar.get_institution_contract(current_user_institution.id) cooperation_history = portal.solar.get_institution_cooperation_history(current_user_institution.id) + logging.info('TEEEEEEEEEEEEEEEEEEEEEEEsst') + logging.info(cooperation_history[0].name) if portal.solar.is_institution_coordinator(current_user_obj.id, current_user_institution.id): contracts_students = portal.solar.get_institution_student_contracts(current_user_institution.id) enable_upload_school_contract = True @@ -761,19 +763,23 @@ def get_upload_file(upload_id, file_hash): if file_hash not in upload_obj.upload_file_hashes: return '', 404 - prefix = file_hash[:2] suffix = file_hash[2:] safe_path = safe_join(str(upload_handler_solar.get_uploads_subdir('files')), prefix, suffix) - f_name = os.listdir(safe_path)[0] + f_name = os.listdir(safe_path)[0] safe_path = safe_join(safe_path, f_name) + + f_suffix = f_name.split('.')[-1] + f_dlname = upload_obj.upload_file_codes[file_hashes.index(file_hash)] + if f_suffix in portal.solar.UploadHandlerSolar.ENABLED_FILETYPES: + f_dlname += '.' + f_suffix + try: - return send_file(safe_path, attachment_filename=f_name, as_attachment=True) + return send_file(safe_path, attachment_filename=f_dlname, as_attachment=True) except FileNotFoundError: return '', 404 - if __name__ == '__main__': app.run(debug=True) diff --git a/portal/solar.py b/portal/solar.py index b5a6d26..e7ca3ac 100644 --- a/portal/solar.py +++ b/portal/solar.py @@ -508,22 +508,18 @@ def get_institution_contract(institution_id): def get_institution_cooperation_history(institution_id): - #return CooperationToken.query.join(UserCooperationTokenMapping, -# UserCooperationTokenMapping.cooperation_token == CooperationToken.id).filter(UserCooperationTokenMapping.user == user_id).all() -# - res = dict() - - uch_rows = UserCooperationHistory.query.filter_by(institution=institution_id).order_by(UserCooperationHistory.school_year.desc()).all() - for row in uch_rows: - if row.user not in res: - res[row.user] = { - 'coordinator': [], - 'mentor': [], - 'other': [] - } - res[row.user][row.role].append((row.school_year, row.badge_text)) - - return res + return db.session.query(UserCooperationHistory.role, + UserCooperationHistory.school_year, + UserCooperationHistory.badge_text, + RegisteredUser.name, + ).select_from( + UserCooperationHistory, + ).join( + RegisteredUser, + UserCooperationHistory.user == RegisteredUser.id, + ).filter( + UserCooperationHistory.institution == institution_id, + ).order_by(UserCooperationHistory.school_year.desc()).all() def get_cooperation_history(): diff --git a/templates/solar-pogodbe.html b/templates/solar-pogodbe.html index ef044c5..2ed0354 100644 --- a/templates/solar-pogodbe.html +++ b/templates/solar-pogodbe.html @@ -128,8 +128,26 @@ -->