Ekipa tab restructuring, downloaded file names are now codes.

This commit is contained in:
msinkec 2022-01-06 12:14:58 +01:00
parent 743ebba052
commit 31c2d294fe
3 changed files with 44 additions and 24 deletions

14
app.py
View File

@ -305,6 +305,8 @@ def solar(text):
show_upload_form = True show_upload_form = True
contract_school = portal.solar.get_institution_contract(current_user_institution.id) contract_school = portal.solar.get_institution_contract(current_user_institution.id)
cooperation_history = portal.solar.get_institution_cooperation_history(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): 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) contracts_students = portal.solar.get_institution_student_contracts(current_user_institution.id)
enable_upload_school_contract = True 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: if file_hash not in upload_obj.upload_file_hashes:
return '', 404 return '', 404
prefix = file_hash[:2] prefix = file_hash[:2]
suffix = file_hash[2:] suffix = file_hash[2:]
safe_path = safe_join(str(upload_handler_solar.get_uploads_subdir('files')), prefix, suffix) 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) 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: 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: except FileNotFoundError:
return '', 404 return '', 404
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True) app.run(debug=True)

View File

@ -508,22 +508,18 @@ def get_institution_contract(institution_id):
def get_institution_cooperation_history(institution_id): def get_institution_cooperation_history(institution_id):
#return CooperationToken.query.join(UserCooperationTokenMapping, return db.session.query(UserCooperationHistory.role,
# UserCooperationTokenMapping.cooperation_token == CooperationToken.id).filter(UserCooperationTokenMapping.user == user_id).all() UserCooperationHistory.school_year,
# UserCooperationHistory.badge_text,
res = dict() RegisteredUser.name,
).select_from(
uch_rows = UserCooperationHistory.query.filter_by(institution=institution_id).order_by(UserCooperationHistory.school_year.desc()).all() UserCooperationHistory,
for row in uch_rows: ).join(
if row.user not in res: RegisteredUser,
res[row.user] = { UserCooperationHistory.user == RegisteredUser.id,
'coordinator': [], ).filter(
'mentor': [], UserCooperationHistory.institution == institution_id,
'other': [] ).order_by(UserCooperationHistory.school_year.desc()).all()
}
res[row.user][row.role].append((row.school_year, row.badge_text))
return res
def get_cooperation_history(): def get_cooperation_history():

View File

@ -128,8 +128,26 @@
</div> </div>
</div>--> </div>-->
<div class="row"> <div class="row">
PLACEHOLDER - GRAF SODELOVANJA
</div>
{% set vars = {'prev_schoolyear': ''} %}
{% for item in cooperation_history %}
{% if item.school_year != vars.prev_schoolyear %}
<div class="row">
<b>Šolsko leto {{item.school_year}}</b>
</div>
{% if vars.update({'prev_schoolyear': item.school_year}) %} {% endif %}
{% endif %}
<div class="row">
{{item.name}}
{{item.badge_text}}
</div>
{% endfor %}
<!--<div class="row">
<div class="col-6"> <div class="col-6">
{% for collaborator in collaborators %} {#{% for collaborator in collaborators %}
<div class="team-item"> <div class="team-item">
<div class="team-item-name">{{collaborator.name}}</div> <div class="team-item-name">{{collaborator.name}}</div>
<div class="team-item-collaborations"> <div class="team-item-collaborations">
@ -159,7 +177,7 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</div> </div>-->
@ -168,7 +186,7 @@
<!-- <!--{#
<a href="../logout">Odjavi se</a> <a href="../logout">Odjavi se</a>
{% if is_institution_coordinator %} {% if is_institution_coordinator %}
<br><a href="../manage-institution">Upravljaj z institucijo</a> <br><a href="../manage-institution">Upravljaj z institucijo</a>
@ -320,7 +338,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>--> </div>#}-->
</body> </body>
<script src="https://d3js.org/d3.v6.js"></script> <script src="https://d3js.org/d3.v6.js"></script>
<script> <script>