From af946662d066bdf01740f03cad5d11a1c55a489c Mon Sep 17 00:00:00 2001 From: msinkec Date: Tue, 25 May 2021 14:51:40 +0200 Subject: [PATCH] Predavanja update. --- app.py | 10 ++++++++-- config.ini | 5 +++++ portal/base.py | 5 +++-- portal/predavanja.py | 2 ++ templates/basic-predavanja.html | 4 ++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 63910f4..7473c3a 100644 --- a/app.py +++ b/app.py @@ -44,6 +44,8 @@ MAX_FILES_PER_UPLOAD = int(config['MAX_FILES_PER_UPLOAD']) CONTRACT_CLIENT_CONTACT = config['CONTRACT_CLIENT_CONTACT'] MAIL_SUBJECT = config['MAIL_SUBJECT'] MAIL_BODY = config['MAIL_BODY'] +MAIL_SUBJECT = config['MAIL_SUBJECT_PREDAVANJA'] +MAIL_BODY = config['MAIL_BODY_PREDAVANJA'] SQL_CONN_STR = config['SQL_CONN_STR'] DESC_PREVODI = config['DESC_PREVODI'] DESC_GIGAFIDA = config['DESC_GIGAFIDA'] @@ -81,6 +83,10 @@ if 'PORTALDS4DS1_MAIL_SUBJECT' in os.environ: MAIL_SUBJECT = os.environ['PORTALDS4DS1_MAIL_SUBJECT'] if 'PORTALDS4DS1_MAIL_BODY' in os.environ: MAIL_BODY = os.environ['PORTALDS4DS1_MAIL_BODY'] +if 'PORTALDS4DS1_MAIL_SUBJECT_PREDAVANJA' in os.environ: + MAIL_SUBJECT_PREDAVANJA = os.environ['PORTALDS4DS1_MAIL_SUBJECT_PREDAVANJA'] +if 'PORTALDS4DS1_MAIL_BODY_PREDAVANJA' in os.environ: + MAIL_BODY_PREDAVANJA = os.environ['PORTALDS4DS1_MAIL_BODY_PREDAVANJA'] if 'PORTALDS4DS1_SQL_CONN_STR' in os.environ: SQL_CONN_STR = os.environ['PORTALDS4DS1_SQL_CONN_STR'] if 'PORTALDS4DS1_DESC_PREVODI' in os.environ: @@ -148,8 +154,8 @@ upload_handler_predavanja = portal.predavanja.UploadHandlerPredavanja( MAIL_PASS=MAIL_PASS, SMTP_PORT=SMTP_PORT, IMAP_PORT=IMAP_PORT, - MAIL_SUBJECT=MAIL_SUBJECT, - MAIL_BODY=MAIL_BODY, + MAIL_SUBJECT=MAIL_SUBJECT_PREDAVANJA, + MAIL_BODY=MAIL_BODY_PREDAVANJA, CONTRACT_CLIENT_CONTACT=CONTRACT_CLIENT_CONTACT, MAX_FILES_PER_UPLOAD=MAX_FILES_PER_UPLOAD ) diff --git a/config.ini b/config.ini index 0b41d03..dff12bf 100644 --- a/config.ini +++ b/config.ini @@ -19,3 +19,8 @@ MAIL_BODY=Hvala, ker ste prispevali besedila in na ta način pomagali pri razvoj Lep pozdrav, ekipa RSDO +MAIL_SUBJECT_PREDAVANJA=Projekt ON ({upload_id}) +MAIL_BODY_PREDAVANJA=Spoštovani, sodelavci projekta ON se vam zahvaljujemo za prispevek in sodelovanje. Morebitna vprašanja pošljite na naslov predavajalnik@cjvt.si. + + Hvala in lep pozdrav, + ekipa CJVT UL diff --git a/portal/base.py b/portal/base.py index c856060..ab086cb 100644 --- a/portal/base.py +++ b/portal/base.py @@ -22,7 +22,6 @@ from jinja2 import Environment, FileSystemLoader from . model import db, UploadRegular, UploadSolar, RegisteredUser, CorpusAccess, Institution -ENABLED_FILETYPES = ['txt', 'csv', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'xml', 'mxliff', 'tmx'] REGEX_EMAIL = re.compile('^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$') MAX_FNAME_LEN = 100 @@ -62,6 +61,8 @@ class ContractCreator: class UploadHandler: + ENABLED_FILETYPES = ['txt', 'csv', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'xml', 'mxliff', 'tmx'] + def __init__(self, **kwargs): self.config = kwargs @@ -199,7 +200,7 @@ class UploadHandler: for key, f in files.items(): if key.startswith('file'): suffix = f.filename.split('.')[-1] - if suffix not in ENABLED_FILETYPES: + if ENABLED_FILETYPES and suffix not in ENABLED_FILETYPES: return 'Datoteka "{}" ni pravilnega formata.'.format(f.filename) return None diff --git a/portal/predavanja.py b/portal/predavanja.py index 898522b..43b6f26 100644 --- a/portal/predavanja.py +++ b/portal/predavanja.py @@ -12,6 +12,8 @@ MAXLEN_FORM = 150 class UploadHandlerPredavanja(UploadHandler): + ENABLED_FILETYPES = None # None means all filetypes + def __init__(self, **kwargs): super().__init__(**kwargs) self.contract_creator = ContractCreator(base_path=self.get_uploads_subdir('contracts'), diff --git a/templates/basic-predavanja.html b/templates/basic-predavanja.html index 13d2ef7..af5ec0c 100644 --- a/templates/basic-predavanja.html +++ b/templates/basic-predavanja.html @@ -105,8 +105,8 @@ uploadMultiple: true, parallelUploads: {{max_files}}, paramName: "file", // The name that will be used to transfer the file - maxFilesize: 1000, // MB - acceptedFiles: ".txt, .csv, .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx", + maxFilesize: 10000, // MB + //acceptedFiles: ".txt, .csv, .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx", maxFiles: {{max_files}}, dictDefaultMessage: `Kliknite ali odložite datoteke sem.`, dictFallbackMessage: "Vaš brskalnik ne podpira izbiranje datotek z odlaganjem (\"drag & drop\").",