|
|
|
@ -6,15 +6,10 @@ import traceback
|
|
|
|
|
import ssl
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from sqlalchemy import desc
|
|
|
|
|
from collections import Counter
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import imaplib
|
|
|
|
|
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.text import MIMEText
|
|
|
|
|
from email.mime.application import MIMEApplication
|
|
|
|
@ -30,9 +25,9 @@ from . model import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
|
|
|
|
VALID_SUBJECTS = {'slo', 'drug-jez', 'drug-druz', 'drug-narav', 'drug-strok', 'drug-izb'}
|
|
|
|
|
VALID_TEXT_TYPES = {'esej-spis', 'prakticno', 'solski-test', 'delo-v-razredu'}
|
|
|
|
|
VALID_GRAMMAR_CORRECTIONS = {'popr-ne', 'brez-popr', 'popr-da'}
|
|
|
|
|
VALID_SUBJECTS = {'SLO', 'DJP', 'DDP', 'DNP', 'DSP', 'DIP'}
|
|
|
|
|
VALID_TEXT_TYPES = {'E', 'PB', 'T', 'R'}
|
|
|
|
|
VALID_GRAMMAR_CORRECTIONS = {'DD', 'N', 'DN'}
|
|
|
|
|
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}$')
|
|
|
|
@ -157,21 +152,45 @@ class UploadHandlerSolar():
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
upload_user = user_id,
|
|
|
|
|
institution = institution_id,
|
|
|
|
|
upload_hash=upload_metadata['upload_id'],
|
|
|
|
|
timestamp=timestamp,
|
|
|
|
|
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'],
|
|
|
|
|
region=region,
|
|
|
|
|
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,
|
|
|
|
|
upload_file_hashes=[x[1] 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)
|
|
|
|
|
|
|
|
|
@ -281,6 +300,8 @@ class UploadHandlerSolar():
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def check_form(form):
|
|
|
|
|
logging.info(form)
|
|
|
|
|
region = form['regija']
|
|
|
|
|
program = form['program']
|
|
|
|
|
predmet = form['predmet']
|
|
|
|
|
letnik = int(form['letnik'])
|
|
|
|
@ -288,6 +309,8 @@ class UploadHandlerSolar():
|
|
|
|
|
solsko_leto = form['solsko-leto']
|
|
|
|
|
jezikovni_popravki = form['jezikovni-popravki']
|
|
|
|
|
|
|
|
|
|
if region not in VALID_REGIONS:
|
|
|
|
|
return 'Invalid region "{}"'.format(region)
|
|
|
|
|
if program not in VALID_PROGRAMS:
|
|
|
|
|
return 'Invalid program "{}"'.format(program)
|
|
|
|
|
if predmet not in VALID_SUBJECTS:
|
|
|
|
@ -444,8 +467,9 @@ def get_all_active_users():
|
|
|
|
|
res.append(user)
|
|
|
|
|
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({
|
|
|
|
|
'region': region,
|
|
|
|
|
'program': program,
|
|
|
|
|
'subject': subject,
|
|
|
|
|
'subject_custom': subject_custom,
|
|
|
|
@ -819,3 +843,4 @@ def send_user_activation_mail(user_id, config):
|
|
|
|
|
except Exception:
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|