Upload file codes, upload region.
This commit is contained in:
parent
a72c5f03cf
commit
9e93d41bc3
|
@ -0,0 +1,30 @@
|
||||||
|
"""Added upload file codes column.
|
||||||
|
|
||||||
|
Revision ID: c7bb822adf9f
|
||||||
|
Revises: 0d9dd68fd94b
|
||||||
|
Create Date: 2021-12-20 09:00:57.208921
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'c7bb822adf9f'
|
||||||
|
down_revision = '0d9dd68fd94b'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('upload_solar', sa.Column('region', sa.String(), nullable=True))
|
||||||
|
op.add_column('upload_solar', sa.Column('upload_file_codes', sa.ARRAY(sa.String()), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('upload_solar', 'upload_file_codes')
|
||||||
|
op.drop_column('upload_solar', 'region')
|
||||||
|
# ### end Alembic commands ###
|
|
@ -19,6 +19,7 @@ class UploadSolar(db.Model):
|
||||||
institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=True)
|
institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=True)
|
||||||
upload_hash = db.Column(db.String, nullable=False)
|
upload_hash = db.Column(db.String, nullable=False)
|
||||||
timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||||
|
region = db.Column(db.String, nullable=True)
|
||||||
program = db.Column(db.String, nullable=True)
|
program = db.Column(db.String, nullable=True)
|
||||||
subject = db.Column(db.String, nullable=True)
|
subject = db.Column(db.String, nullable=True)
|
||||||
subject_custom = db.Column(db.String, nullable=True)
|
subject_custom = db.Column(db.String, nullable=True)
|
||||||
|
@ -29,6 +30,7 @@ class UploadSolar(db.Model):
|
||||||
grammar_corrections = db.Column(db.String, nullable=True)
|
grammar_corrections = db.Column(db.String, nullable=True)
|
||||||
upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True)
|
upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True)
|
||||||
upload_file_names = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True)
|
upload_file_names = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True)
|
||||||
|
upload_file_codes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class ContractsSolar(db.Model):
|
class ContractsSolar(db.Model):
|
||||||
|
|
|
@ -6,15 +6,10 @@ import traceback
|
||||||
import ssl
|
import ssl
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
from collections import Counter
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import imaplib
|
|
||||||
from smtplib import SMTP_SSL
|
from smtplib import SMTP_SSL
|
||||||
|
|
||||||
import email
|
|
||||||
from email import encoders
|
|
||||||
from email.mime.base import MIMEBase
|
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.application import MIMEApplication
|
from email.mime.application import MIMEApplication
|
||||||
|
@ -30,9 +25,9 @@ from . model import *
|
||||||
|
|
||||||
|
|
||||||
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
||||||
VALID_SUBJECTS = {'slo', 'drug-jez', 'drug-druz', 'drug-narav', 'drug-strok', 'drug-izb'}
|
VALID_SUBJECTS = {'SLO', 'DJP', 'DDP', 'DNP', 'DSP', 'DIP'}
|
||||||
VALID_TEXT_TYPES = {'esej-spis', 'prakticno', 'solski-test', 'delo-v-razredu'}
|
VALID_TEXT_TYPES = {'E', 'PB', 'T', 'R'}
|
||||||
VALID_GRAMMAR_CORRECTIONS = {'popr-ne', 'brez-popr', 'popr-da'}
|
VALID_GRAMMAR_CORRECTIONS = {'DD', 'N', 'DN'}
|
||||||
VALID_REGIONS = {'CE', 'GO', 'KK', 'KP', 'KR', 'LJ', 'MB', 'MS', 'NM', 'PO', 'SG'}
|
VALID_REGIONS = {'CE', 'GO', 'KK', 'KP', 'KR', 'LJ', 'MB', 'MS', 'NM', 'PO', 'SG'}
|
||||||
|
|
||||||
#REGEX_EMAIL = re.compile('^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$')
|
#REGEX_EMAIL = re.compile('^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$')
|
||||||
|
@ -157,21 +152,45 @@ class UploadHandlerSolar():
|
||||||
|
|
||||||
institution_id = get_user_institution(user_id).id
|
institution_id = get_user_institution(user_id).id
|
||||||
|
|
||||||
|
region = form_data['regija']
|
||||||
|
program = form_data['program']
|
||||||
|
subject = form_data['predmet'],
|
||||||
|
subject_custom = form_data['predmet-custom'],
|
||||||
|
grade = form_data['letnik'],
|
||||||
|
text_type = form_data['vrsta'],
|
||||||
|
text_type_custom = form_data['vrsta-custom'],
|
||||||
|
school_year = form_data['solsko-leto'],
|
||||||
|
grammar_corrections = form_data['jezikovni-popravki'],
|
||||||
|
upload_file_codes = []
|
||||||
|
for i in range(len(sorted_file_items)):
|
||||||
|
file_code = '{}_{}_{}_{}_{}_{}_{}_{}'.format(
|
||||||
|
region[0],
|
||||||
|
program[0],
|
||||||
|
subject[0],
|
||||||
|
grade[0],
|
||||||
|
text_type[0],
|
||||||
|
school_year[0],
|
||||||
|
grammar_corrections[0],
|
||||||
|
i)
|
||||||
|
upload_file_codes.append(file_code)
|
||||||
|
|
||||||
model_obj = UploadSolar(
|
model_obj = UploadSolar(
|
||||||
upload_user = user_id,
|
upload_user = user_id,
|
||||||
institution = institution_id,
|
institution = institution_id,
|
||||||
upload_hash=upload_metadata['upload_id'],
|
upload_hash=upload_metadata['upload_id'],
|
||||||
timestamp=timestamp,
|
timestamp=timestamp,
|
||||||
program=form_data['program'],
|
region=region,
|
||||||
subject=form_data['predmet'],
|
program=program,
|
||||||
subject_custom=form_data['predmet-custom'],
|
subject=subject,
|
||||||
grade=form_data['letnik'],
|
subject_custom=subject_custom,
|
||||||
text_type=form_data['vrsta'],
|
grade=grade,
|
||||||
text_type_custom=form_data['vrsta-custom'],
|
text_type=text_type,
|
||||||
school_year=form_data['solsko-leto'],
|
text_type_custom=text_type_custom,
|
||||||
grammar_corrections=form_data['jezikovni-popravki'],
|
school_year=school_year,
|
||||||
|
grammar_corrections=grammar_corrections,
|
||||||
upload_file_hashes=[x[1] for x in sorted_file_items],
|
upload_file_hashes=[x[1] for x in sorted_file_items],
|
||||||
upload_file_names=[x[0] for x in sorted_file_items],
|
upload_file_names=[x[0] for x in sorted_file_items],
|
||||||
|
upload_file_codes=upload_file_codes,
|
||||||
)
|
)
|
||||||
UploadHandlerSolar.store_model(model_obj)
|
UploadHandlerSolar.store_model(model_obj)
|
||||||
|
|
||||||
|
@ -281,6 +300,8 @@ class UploadHandlerSolar():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_form(form):
|
def check_form(form):
|
||||||
|
logging.info(form)
|
||||||
|
region = form['regija']
|
||||||
program = form['program']
|
program = form['program']
|
||||||
predmet = form['predmet']
|
predmet = form['predmet']
|
||||||
letnik = int(form['letnik'])
|
letnik = int(form['letnik'])
|
||||||
|
@ -288,6 +309,8 @@ class UploadHandlerSolar():
|
||||||
solsko_leto = form['solsko-leto']
|
solsko_leto = form['solsko-leto']
|
||||||
jezikovni_popravki = form['jezikovni-popravki']
|
jezikovni_popravki = form['jezikovni-popravki']
|
||||||
|
|
||||||
|
if region not in VALID_REGIONS:
|
||||||
|
return 'Invalid region "{}"'.format(region)
|
||||||
if program not in VALID_PROGRAMS:
|
if program not in VALID_PROGRAMS:
|
||||||
return 'Invalid program "{}"'.format(program)
|
return 'Invalid program "{}"'.format(program)
|
||||||
if predmet not in VALID_SUBJECTS:
|
if predmet not in VALID_SUBJECTS:
|
||||||
|
@ -444,8 +467,9 @@ 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):
|
def update_upload_item(item_id, region, 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({
|
rowcount = db.session.query(UploadSolar).filter_by(id=item_id).update({
|
||||||
|
'region': region,
|
||||||
'program': program,
|
'program': program,
|
||||||
'subject': subject,
|
'subject': subject,
|
||||||
'subject_custom': subject_custom,
|
'subject_custom': subject_custom,
|
||||||
|
@ -819,3 +843,4 @@ def send_user_activation_mail(user_id, config):
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,30 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<label>Program</label>
|
<label for="regija">Regija</label>
|
||||||
|
<select id="regija" name="regija">
|
||||||
|
<option value="CE" selected="selected">Celje (CE)</option>
|
||||||
|
<option value="GO">Nova Gorica (GO)</option>
|
||||||
|
<option value="KK">Krško (KK)</option>
|
||||||
|
<option value="KP">Koper (KP)</option>
|
||||||
|
<option value="KR">Kranj (KR)</option>
|
||||||
|
<option value="LJ">Ljubljana (LJ)</option>
|
||||||
|
<option value="MB">Maribor (MB)</option>
|
||||||
|
<option value="MS">Murska Sobota (MS)</option>
|
||||||
|
<option value="NM">Novo Mesto (NM)</option>
|
||||||
|
<option value="PO">Postojna (PO)</option>
|
||||||
|
<option value="SG">Slovenj Gradec (SG)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="form-wrapper">
|
||||||
|
<label for="program">Program</label>
|
||||||
<select id="program" name="program">
|
<select id="program" name="program">
|
||||||
<option value="OS" selected="selected">Osnovnošolski (OŠ)</option>
|
<option value="OS" selected="selected">Osnovnošolski (OŠ)</option>
|
||||||
<option value="SSG">Splošna in strokovna gimnazija (SGG)</option>
|
<option value="SSG">Splošna in strokovna gimnazija (SGG)</option>
|
||||||
|
@ -77,7 +100,7 @@
|
||||||
<option value="NPI">Nižje poklicno izobraževanje (NPI)</option>
|
<option value="NPI">Nižje poklicno izobraževanje (NPI)</option>
|
||||||
<option value="SPI">Srednje poklicno izobraževanje (SPI)</option>
|
<option value="SPI">Srednje poklicno izobraževanje (SPI)</option>
|
||||||
<option value="SSI">Srednje strokovno izobraževanje (SSI)</option>
|
<option value="SSI">Srednje strokovno izobraževanje (SSI)</option>
|
||||||
<option value="PTI">Poklicno-tehnično izobraževanje (PTI)</option>
|
<option value="PTI">Poklicno-tehniško izobraževanje (PTI)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,12 +113,12 @@
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<label for="predmet">Predmet</label>
|
<label for="predmet">Predmet</label>
|
||||||
<select id="predmet" name="predmet">
|
<select id="predmet" name="predmet">
|
||||||
<option value="slo" selected="selected">Slovenščina</option>
|
<option value="SLO" selected="selected">Slovenščina (SLO)</option>
|
||||||
<option value="drug-jez">Drugi jezikoslovni predmeti</option>
|
<option value="DJP">Drugi jezikoslovni predmeti (vtipkajte ime predmeta) (DJP)</option>
|
||||||
<option value="drug-druz">Drugi družboslovni predmeti</option>
|
<option value="DDP">Drugi družboslovni predmeti (vtipkajte ime predmeta) (DDP)</option>
|
||||||
<option value="drug-narav">Drugi naravoslovni predmeti</option>
|
<option value="DNP">Drugi naravoslovni predmeti (vtipkajte ime predmeta) (DNP)</option>
|
||||||
<option value="drug-strok">Drugi strokovni predmeti</option>
|
<option value="DSP">Drugi strokovni predmeti (vtipkajte ime predmeta) (DSP)</option>
|
||||||
<option value="drug-izb">Drugi izbirni ali dodatni predmeti</option>
|
<option value="DIP">Drugi izbirni ali dodatni predmeti (vtipkajte ime predmeta) (DIP)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -143,10 +166,10 @@
|
||||||
<div class="form-wrapper" >
|
<div class="form-wrapper" >
|
||||||
<label for="vrsta">Vrsta besedila</label>
|
<label for="vrsta">Vrsta besedila</label>
|
||||||
<select id="vrsta" name="vrsta">
|
<select id="vrsta" name="vrsta">
|
||||||
<option value="esej-spis" selected="selected">Esej ali spis</option>
|
<option value="E" selected="selected">Esej ali spis (E)</option>
|
||||||
<option value="prakticno">Praktično besedilo (npr. vabila, prošnje ipd. pri pouku slovenščine), napisano za oceno</option>
|
<option value="PB">Praktično besedilo (npr. vabila, prošnje ipd. pri pouku slovenščine), napisano za oceno (PB)</option>
|
||||||
<option value="solski-test">Šolski test</option>
|
<option value="T">Šolski test (T)</option>
|
||||||
<option value="delo-v-razredu">Delo v razredu, ne za oceno</option>
|
<option value="R">Delo v razredu, ne za oceno (vtipkajte besedilo vrsto) (R)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -187,9 +210,9 @@
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<label for="jezikovni-popravki">Jezikovni popravki</label>
|
<label for="jezikovni-popravki">Jezikovni popravki</label>
|
||||||
<select id="jezikovni-popravki" name="jezikovni-popravki">
|
<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="DD" selected="selected">Besedilo vsebuje učiteljske popravke in strinjam se z njihovo vključitvijo v korpus. (DD)</option>
|
||||||
<option value="brez-popr">Besedilo ne vsebuje učiteljskih popravkov</option>
|
<option value="N">Besedilo ne vsebuje učiteljskih popravkov. (N)</option>
|
||||||
<option value="popr-da">Besedilo vsebuje učiteljske popravke in ne strinjam se z njihovo vključitvijo v korpus</option>
|
<option value="DN">Besedilo vsebuje učiteljske popravke in ne strinjam se z njihovo vključitvijo v korpus. (DN)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -295,7 +318,7 @@
|
||||||
//onready
|
//onready
|
||||||
selectPredmet.addEventListener("change", function(e) {
|
selectPredmet.addEventListener("change", function(e) {
|
||||||
var predmetCustomBox = document.getElementById("predmet-custom-box").closest('.row');
|
var predmetCustomBox = document.getElementById("predmet-custom-box").closest('.row');
|
||||||
if (selectPredmet.value.startsWith("drug")) {
|
if (selectPredmet.value.startsWith("D")) {
|
||||||
predmetCustomBox.style.maxHeight = "150px";
|
predmetCustomBox.style.maxHeight = "150px";
|
||||||
} else {
|
} else {
|
||||||
predmetCustomBox.style.maxHeight = "0px";
|
predmetCustomBox.style.maxHeight = "0px";
|
||||||
|
@ -304,7 +327,7 @@
|
||||||
|
|
||||||
selectVrsta.addEventListener("change", function(e) {
|
selectVrsta.addEventListener("change", function(e) {
|
||||||
var vrstaCustomBox = document.getElementById("vrsta-custom-box").closest('.row');
|
var vrstaCustomBox = document.getElementById("vrsta-custom-box").closest('.row');
|
||||||
if (selectVrsta.value == "delo-v-razredu") {
|
if (selectVrsta.value == "R") {
|
||||||
vrstaCustomBox.style.maxHeight = "150px";
|
vrstaCustomBox.style.maxHeight = "150px";
|
||||||
} else {
|
} else {
|
||||||
vrstaCustomBox.style.maxHeight = "0px";
|
vrstaCustomBox.style.maxHeight = "0px";
|
||||||
|
@ -351,6 +374,7 @@
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
// Check form validity.
|
// Check form validity.
|
||||||
|
var regija = form["regija"].value;
|
||||||
var program = form["program"].value;
|
var program = form["program"].value;
|
||||||
var predmet = form["predmet"].value;
|
var predmet = form["predmet"].value;
|
||||||
var predmetCustom = form["predmet-custom"].value;
|
var predmetCustom = form["predmet-custom"].value;
|
||||||
|
@ -360,9 +384,9 @@
|
||||||
var solskoLeto = form["solsko-leto"].value;
|
var solskoLeto = form["solsko-leto"].value;
|
||||||
var jezikovniPopravki = form["jezikovni-popravki"].value;
|
var jezikovniPopravki = form["jezikovni-popravki"].value;
|
||||||
|
|
||||||
if (predmet.startsWith("drug") && isEmptyOrSpaces(predmetCustom)) {
|
if (predmet.startsWith("D") && isEmptyOrSpaces(predmetCustom)) {
|
||||||
showError("Polje za predmet ne more biti prazno!");
|
showError("Polje za predmet ne more biti prazno!");
|
||||||
} else if (vrsta === "delo-v-razredu" && isEmptyOrSpaces(vrstaCustom)) {
|
} else if (vrsta === "R" && isEmptyOrSpaces(vrstaCustom)) {
|
||||||
showError("Polje za vrsto besedila ne more biti prazno!");
|
showError("Polje za vrsto besedila ne more biti prazno!");
|
||||||
} else if (dataConfirmNotification.style.display == "none") {
|
} else if (dataConfirmNotification.style.display == "none") {
|
||||||
dataConfirmNotification.style.display = "inherit";
|
dataConfirmNotification.style.display = "inherit";
|
||||||
|
@ -409,6 +433,7 @@
|
||||||
|
|
||||||
|
|
||||||
this.on("sending", function(file, xhr, formData) {
|
this.on("sending", function(file, xhr, formData) {
|
||||||
|
formData.append("regija",form["regija"].value);
|
||||||
formData.append("program",form["program"].value);
|
formData.append("program",form["program"].value);
|
||||||
formData.append("predmet",form["predmet"].value);
|
formData.append("predmet",form["predmet"].value);
|
||||||
formData.append("predmet-custom",form["predmet-custom"].value);
|
formData.append("predmet-custom",form["predmet-custom"].value);
|
||||||
|
|
|
@ -130,6 +130,10 @@
|
||||||
<div class="file-item">
|
<div class="file-item">
|
||||||
<div class="file-icon"><img src="/static/image/file.svg"/></div>
|
<div class="file-icon"><img src="/static/image/file.svg"/></div>
|
||||||
<a href="getuploadfile/{{item.id}}/{{item.upload_file_hashes[loop.index - 1]}}" class="file-name">{{f_name}}</a>
|
<a href="getuploadfile/{{item.id}}/{{item.upload_file_hashes[loop.index - 1]}}" class="file-name">{{f_name}}</a>
|
||||||
|
</br>
|
||||||
|
{% if item.upload_file_codes != None %}
|
||||||
|
<div>{{item.upload_file_codes[loop.index - 1]}}</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user