Predavanja update.
This commit is contained in:
@@ -152,7 +152,7 @@ class UploadHandler:
|
||||
f.save(path / f.filename)
|
||||
|
||||
|
||||
def send_confirm_mail(self, upload_metadata):
|
||||
def send_confirm_mail(self, upload_metadata, attach_contract_file=False):
|
||||
upload_id = upload_metadata['upload_id']
|
||||
|
||||
message = MIMEMultipart()
|
||||
@@ -162,17 +162,18 @@ class UploadHandler:
|
||||
body = self.config['MAIL_BODY'].format(upload_id=upload_id)
|
||||
message.attach(MIMEText(body, "plain"))
|
||||
|
||||
contracts_dir = self.contract_creator.base
|
||||
f_name = upload_metadata['contract_file']
|
||||
sub_dir = contracts_dir / Path(f_name[:2])
|
||||
contract_file = sub_dir / Path(f_name[2:])
|
||||
with open(contract_file, "rb") as f:
|
||||
part = MIMEApplication(
|
||||
f.read(),
|
||||
Name = f_name
|
||||
)
|
||||
part['Content-Disposition'] = 'attachment; filename="%s"' % f_name
|
||||
message.attach(part)
|
||||
if attach_contract_file:
|
||||
contracts_dir = self.contract_creator.base
|
||||
f_name = upload_metadata['contract_file']
|
||||
sub_dir = contracts_dir / Path(f_name[:2])
|
||||
contract_file = sub_dir / Path(f_name[2:])
|
||||
with open(contract_file, "rb") as f:
|
||||
part = MIMEApplication(
|
||||
f.read(),
|
||||
Name = f_name
|
||||
)
|
||||
part['Content-Disposition'] = 'attachment; filename="%s"' % f_name
|
||||
message.attach(part)
|
||||
|
||||
text = message.as_string()
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ class UploadPredavanja(db.Model):
|
||||
email = db.Column(db.String, nullable=False)
|
||||
phone = db.Column(db.String, nullable=True)
|
||||
keywords = db.Column(db.String, nullable=False)
|
||||
agree_publish = db.Column(db.Boolean, nullable=False)
|
||||
agree_publish_future = db.Column(db.String, nullable=False)
|
||||
agree_machine_translation = db.Column(db.Boolean, default=False, nullable=False)
|
||||
agree_news_cjvt = db.Column(db.Boolean, default=False, nullable=False)
|
||||
|
||||
@@ -53,7 +53,6 @@ class UploadHandlerPredavanja(UploadHandler):
|
||||
email=form_data['email'],
|
||||
phone=form_data.get('phone'),
|
||||
keywords=form_data['kljucne-besede'],
|
||||
agree_publish=True if 'kljucne-besde' in form_data else False,
|
||||
agree_publish_future=form_data['javna-objava-prihodnost'],
|
||||
agree_machine_translation=True if 'strojno-prevajanje' in form_data else False,
|
||||
agree_news_cjvt=True if 'obvestila' in form_data else False,
|
||||
@@ -80,16 +79,13 @@ class UploadHandlerPredavanja(UploadHandler):
|
||||
logging.info('Upload for "predavanja" with id "{}" supplied form data: {}'.format(
|
||||
upload_metadata['upload_id'], str(upload_metadata['form_data'])))
|
||||
|
||||
# Generate contract PDF file based on the uploads metadata.
|
||||
self.generate_upload_contract_pdf(upload_metadata)
|
||||
|
||||
# Store uploaded files to disk.
|
||||
self.store_datafiles(request.files, upload_metadata)
|
||||
|
||||
# Store metadata to database.
|
||||
self.store_metadata(upload_metadata)
|
||||
|
||||
# Send confirmation mail along with the contract to the submitted email address.
|
||||
# Send confirmation mail
|
||||
self.send_confirm_mail(upload_metadata)
|
||||
|
||||
return 'Uspešno ste oddali datotek(e). Št. datotek: {}'.format(len(request.files))
|
||||
|
||||
@@ -89,7 +89,7 @@ class UploadHandlerRegular(UploadHandler):
|
||||
self.store_metadata(upload_metadata, corpus_name)
|
||||
|
||||
# Send confirmation mail along with the contract to the submitted email address.
|
||||
self.send_confirm_mail(upload_metadata)
|
||||
self.send_confirm_mail(upload_metadata, attach_contract_file=True)
|
||||
|
||||
return 'Uspešno ste oddali datotek(e). Št. datotek: {}'.format(len(request.files))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user