Edit upload items in administration menu.
This commit is contained in:
parent
965ddee7a7
commit
7d9d2b175c
42
app.py
42
app.py
|
@ -374,9 +374,10 @@ def solar(text):
|
||||||
inactive_users = portal.base.get_all_users_join_institutions(active=False)
|
inactive_users = portal.base.get_all_users_join_institutions(active=False)
|
||||||
solar_institutions = portal.solar.get_all_institutions()
|
solar_institutions = portal.solar.get_all_institutions()
|
||||||
cooperation_history = portal.base.get_cooperation_history()
|
cooperation_history = portal.base.get_cooperation_history()
|
||||||
|
uploads = portal.solar.get_all_upload_history(-1)
|
||||||
if is_admin:
|
if is_admin:
|
||||||
return render_template('solar-admin.html', users=users, user_cooperation_history=cooperation_history,
|
return render_template('solar-admin.html', users=users, user_cooperation_history=cooperation_history,
|
||||||
institutions=solar_institutions, inactive_users=inactive_users)
|
institutions=solar_institutions, inactive_users=inactive_users, uploads=uploads)
|
||||||
elif text.startswith('manage-institution/') or text == 'manage-institution':
|
elif text.startswith('manage-institution/') or text == 'manage-institution':
|
||||||
if portal.base.is_institution_coordinator(current_user.id, current_user_institution.id):
|
if portal.base.is_institution_coordinator(current_user.id, current_user_institution.id):
|
||||||
solar_users = portal.base.get_all_active_users()
|
solar_users = portal.base.get_all_active_users()
|
||||||
|
@ -612,6 +613,45 @@ def add_cooperation_history_item():
|
||||||
flash('Vnos dodan.')
|
flash('Vnos dodan.')
|
||||||
return redirect(redirect_url())
|
return redirect(redirect_url())
|
||||||
|
|
||||||
|
@app.route('/solar/updateuploaditem', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def update_upload_item():
|
||||||
|
if not portal.base.is_admin(current_user.id):
|
||||||
|
return '', 404
|
||||||
|
|
||||||
|
err_msg = portal.solar.UploadHandlerSolar.check_form(request.form)
|
||||||
|
if err_msg:
|
||||||
|
flash(err_msg)
|
||||||
|
return redirect(redirect_url())
|
||||||
|
|
||||||
|
item_id = request.form.get('item-id')
|
||||||
|
program = request.form.get('program')
|
||||||
|
subject = request.form.get('predmet')
|
||||||
|
subject_custom = request.form.get('predmet-custom')
|
||||||
|
grade = request.form.get('letnik')
|
||||||
|
text_type = request.form.get('vrsta')
|
||||||
|
text_type_custom = request.form.get('vrsta-custom')
|
||||||
|
school_year = request.form.get('solsko-leto')
|
||||||
|
grammar_corrections = request.form.get('jezikovni-popravki')
|
||||||
|
|
||||||
|
rowcount = portal.solar.update_upload_item(
|
||||||
|
item_id,
|
||||||
|
program,
|
||||||
|
subject,
|
||||||
|
subject_custom,
|
||||||
|
grade,
|
||||||
|
text_type,
|
||||||
|
text_type_custom,
|
||||||
|
school_year,
|
||||||
|
grammar_corrections)
|
||||||
|
|
||||||
|
if rowcount == 0:
|
||||||
|
return '', 404
|
||||||
|
|
||||||
|
flash('Vnos spremenjen.')
|
||||||
|
return redirect(redirect_url())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/solar/delcooperationhistoryitem', methods=['POST'])
|
@app.route('/solar/delcooperationhistoryitem', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def del_cooperation_history_item():
|
def del_cooperation_history_item():
|
||||||
|
|
|
@ -6,7 +6,7 @@ from sqlalchemy import desc
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
from portal.base import UploadHandler, get_user_institution, has_user_corpus_access
|
from portal.base import UploadHandler, get_user_institution, has_user_corpus_access
|
||||||
from portal.model import UploadSolar, ContractsSolar, RegisteredUser, Institution, InstitutionContract, UserInstitutionMapping, CorpusAccess
|
from . model import *
|
||||||
|
|
||||||
|
|
||||||
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
||||||
|
@ -161,12 +161,19 @@ class UploadHandlerSolar(UploadHandler):
|
||||||
|
|
||||||
|
|
||||||
def get_upload_history(user_id, n=20):
|
def get_upload_history(user_id, n=20):
|
||||||
|
if n == -1:
|
||||||
|
return UploadSolar.query.filter_by(upload_user=user_id).order_by(desc(UploadSolar.timestamp)).all()
|
||||||
return UploadSolar.query.filter_by(upload_user=user_id).order_by(desc(UploadSolar.timestamp)).limit(n).all()
|
return UploadSolar.query.filter_by(upload_user=user_id).order_by(desc(UploadSolar.timestamp)).limit(n).all()
|
||||||
|
|
||||||
|
|
||||||
def get_institution_upload_history(institution_id, n=20):
|
def get_institution_upload_history(institution_id, n=20):
|
||||||
return UploadSolar.query.filter_by(institution=institution_id).order_by(desc(UploadSolar.timestamp)).limit(n).all()
|
return UploadSolar.query.filter_by(institution=institution_id).order_by(desc(UploadSolar.timestamp)).limit(n).all()
|
||||||
|
|
||||||
|
def get_all_upload_history(n=20):
|
||||||
|
if n == -1:
|
||||||
|
return UploadSolar.query.order_by(desc(UploadSolar.timestamp)).all()
|
||||||
|
return UploadSolar.query.order_by(desc(UploadSolar.timestamp)).limit(n).all()
|
||||||
|
|
||||||
|
|
||||||
def get_all_institutions():
|
def get_all_institutions():
|
||||||
# TODO: do filtering purely within an SQL query
|
# TODO: do filtering purely within an SQL query
|
||||||
|
@ -211,3 +218,16 @@ def get_all_active_users():
|
||||||
res.append(user)
|
res.append(user)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def update_upload_item(item_id, program, subject, subject_custom, grade, text_type, text_type_custom, school_year, grammar_corrections):
|
||||||
|
rowcount = db.session.query(UploadSolar).filter_by(id=item_id).update({
|
||||||
|
'program': program,
|
||||||
|
'subject': subject,
|
||||||
|
'subject_custom': subject_custom,
|
||||||
|
'grade': grade,
|
||||||
|
'text_type': text_type,
|
||||||
|
'text_type_custom': text_type_custom,
|
||||||
|
'school_year': school_year,
|
||||||
|
'grammar_corrections': grammar_corrections
|
||||||
|
})
|
||||||
|
db.session.commit()
|
||||||
|
return rowcount
|
||||||
|
|
|
@ -279,4 +279,136 @@
|
||||||
<input type="text" id="entry-id" name="entry-id"><br>
|
<input type="text" id="entry-id" name="entry-id"><br>
|
||||||
<input type="submit" value="Odstrani">
|
<input type="submit" value="Odstrani">
|
||||||
</form>
|
</form>
|
||||||
|
<h2>Nalaganja</h2>
|
||||||
|
<div class="tableFixHead">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>ID uporabnika</th>
|
||||||
|
<th>ID institucije</th>
|
||||||
|
<th>Čas nalaganja</th>
|
||||||
|
<th>Program</th>
|
||||||
|
<th>Predmet</th>
|
||||||
|
<th>Predmet (drugo)</th>
|
||||||
|
<th>Letnik</th>
|
||||||
|
<th>Vrsta besedila</th>
|
||||||
|
<th>Vrsta besedila (drugo)</th>
|
||||||
|
<th>Šolsko leto</th>
|
||||||
|
<th>Jezikovni popravki</th>
|
||||||
|
<th>ID-ji naloženih datotek</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in uploads %}
|
||||||
|
<tr>
|
||||||
|
<td>{{item.id}}</td>
|
||||||
|
<td>{{item.upload_user}}</td>
|
||||||
|
<td>{{item.institution}}</td>
|
||||||
|
<td>{{item.timestamp}}</td>
|
||||||
|
<td>{{item.program}}</td>
|
||||||
|
<td>{{item.subject}}</td>
|
||||||
|
<td>{{item.subject_custom}}</td>
|
||||||
|
<td>{{item.grade}}</td>
|
||||||
|
<td>{{item.text_type}}</td>
|
||||||
|
<td>{{item.text_type_custom}}</td>
|
||||||
|
<td>{{item.school_year}}</td>
|
||||||
|
<td>{{item.grammar_corrections}}</td>
|
||||||
|
<td>{{item.upload_file_hashes}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h3>Posodobi podatke nalaganja</h3>
|
||||||
|
<form action="/solar/updateuploaditem" method="post">
|
||||||
|
<label for="item-id">ID nalaganja</label>
|
||||||
|
<input type="text" id="item-id" name="item-id"/><br>
|
||||||
|
<label for="program">Program</label>
|
||||||
|
<select id="program" name="program">
|
||||||
|
<option value="OS" selected="selected">Osnovnošolski (OŠ)</option>
|
||||||
|
<option value="SSG">Splošna in strokovna gimnazija (SGG)</option>
|
||||||
|
<option value="MGP">Mednarodni gimnazijski programi (MGP)</option>
|
||||||
|
<option value="ZG">Zasebne gimnazije (ZG)</option>
|
||||||
|
<option value="NPI">Nižje poklicno izobraževanje (NPI)</option>
|
||||||
|
<option value="SPI">Srednje poklicno izobraževanje (SPI)</option>
|
||||||
|
<option value="SSI">Srednje strokovno izobraževanje (SSI)</option>
|
||||||
|
<option value="PTI">Poklicno-tehnično izobraževanje (PTI)</option>
|
||||||
|
</select><br>
|
||||||
|
|
||||||
|
<label for="predmet">Predmet</label>
|
||||||
|
<select id="predmet" name="predmet">
|
||||||
|
<option value="slo" selected="selected">Slovenščina</option>
|
||||||
|
<option value="drug-jez">Drugi jezikoslovni predmeti</option>
|
||||||
|
<option value="drug-druz">Drugi družboslovni predmeti</option>
|
||||||
|
<option value="drug-narav">Drugi naravoslovni predmeti</option>
|
||||||
|
<option value="drug-strok">Drugi strokovni predmeti</option>
|
||||||
|
<option value="drug-izb">Drugi izbirni ali dodatni predmeti</option>
|
||||||
|
</select><br>
|
||||||
|
<div id="predmet-custom-box" style="display: none;">
|
||||||
|
<label for="predmet-custom">Ime predmeta:</label>
|
||||||
|
<input type="text" id="predmet-custom" name="predmet-custom"/><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label for="letnik">Letnik</label>
|
||||||
|
<select id="letnik" name="letnik">
|
||||||
|
<option value="1" selected="selected">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="3">3</option>
|
||||||
|
<option value="4">4</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="6">6</option>
|
||||||
|
<option value="7">7</option>
|
||||||
|
<option value="8">8</option>
|
||||||
|
<option value="9">9</option>
|
||||||
|
</select><br>
|
||||||
|
|
||||||
|
<label for="vrsta">Vrsta besedila</label>
|
||||||
|
<select id="vrsta" name="vrsta">
|
||||||
|
<option value="esej-spis" selected="selected">Esej ali spis</option>
|
||||||
|
<option value="prakticno">Praktično besedilo (npr. vabila, prošnje ipd. pri pouku slovenščine), napisano za oceno</option>
|
||||||
|
<option value="solski-test">Šolski test</option>
|
||||||
|
<option value="delo-v-razredu">Delo v razredu, ne za oceno</option>
|
||||||
|
</select>
|
||||||
|
<div id="vrsta-custom-box" style="display: none;">
|
||||||
|
<label for="vrsta-custom">Vtipkajte besedilno vrsto:</label>
|
||||||
|
<input type="text" id="vrsta-custom" name="vrsta-custom"/><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label for="solsko-leto">Šolsko leto</label>
|
||||||
|
<select id="solsko-leto" name="solsko-leto">
|
||||||
|
<option value="20-21" selected="selected">2020/21</option>
|
||||||
|
<option value="21-22">2021/22</option>
|
||||||
|
</select><br>
|
||||||
|
|
||||||
|
<label for="jezikovni-popravki">Jezikovni popravki</label>
|
||||||
|
<select id="jezikovni-popravki" name="jezikovni-popravki">
|
||||||
|
<option value="popr-ne" selected="selected">Besedilo vsebuje učiteljske popravke in strinjam se z njihovo vključitvijo v korpus</option>
|
||||||
|
<option value="brez-popr">Besedilo ne vsebuje učiteljskih popravkov</option>
|
||||||
|
<option value="popr-da">Besedilo vsebuje učiteljske popravke in ne strinjam se z njihovo vključitvijo v korpus</option>
|
||||||
|
</select><br>
|
||||||
|
|
||||||
|
<button id="button-submit" type="submit">Posodobi</button>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
var selectPredmet = document.getElementById("predmet");
|
||||||
|
var selectVrsta = document.getElementById("vrsta");
|
||||||
|
|
||||||
|
selectPredmet.addEventListener("change", function(e) {
|
||||||
|
var predmetCustomBox = document.getElementById("predmet-custom-box");
|
||||||
|
if (selectPredmet.value.startsWith("drug")) {
|
||||||
|
predmetCustomBox.style.display = "inherit";
|
||||||
|
} else {
|
||||||
|
predmetCustomBox.style.display = "none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
selectVrsta.addEventListener("change", function(e) {
|
||||||
|
var vrstaCustomBox = document.getElementById("vrsta-custom-box");
|
||||||
|
if (selectVrsta.value == "delo-v-razredu") {
|
||||||
|
vrstaCustomBox.style.display = "inherit";
|
||||||
|
} else {
|
||||||
|
vrstaCustomBox.style.display = "none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user