1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 01:50:31 +00:00

#1141 (Setting for file size limit on email)

This commit is contained in:
Ozzieisaacs 2020-05-09 20:29:17 +02:00
parent fefb44e612
commit 308fd55483
4 changed files with 24 additions and 21 deletions

View File

@ -485,8 +485,8 @@ def basic_configuration():
return _configuration_result() return _configuration_result()
def _config_int(to_save, x): def _config_int(to_save, x, func=int):
return config.set_from_dictionary(to_save, x, int) return config.set_from_dictionary(to_save, x, func)
def _config_checkbox(to_save, x): def _config_checkbox(to_save, x):
@ -694,7 +694,7 @@ def _configuration_update_helper():
if not db.setup_db(config): if not db.setup_db(config):
return _configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), gdriveError) return _configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), gdriveError)
if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK): if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK):
flash(_(u"DB is not writeable"), category="warning") flash(_(u"DB is not Writeable"), category="warning")
config.save() config.save()
flash(_(u"Calibre-Web configuration updated"), category="success") flash(_(u"Calibre-Web configuration updated"), category="success")
@ -901,7 +901,7 @@ def edit_mailsettings():
@admin_required @admin_required
def update_mailsettings(): def update_mailsettings():
to_save = request.form.to_dict() to_save = request.form.to_dict()
log.debug("update_mailsettings %r", to_save) # log.debug("update_mailsettings %r", to_save)
_config_string(to_save, "mail_server") _config_string(to_save, "mail_server")
_config_int(to_save, "mail_port") _config_int(to_save, "mail_port")
@ -909,6 +909,7 @@ def update_mailsettings():
_config_string(to_save, "mail_login") _config_string(to_save, "mail_login")
_config_string(to_save, "mail_password") _config_string(to_save, "mail_password")
_config_string(to_save, "mail_from") _config_string(to_save, "mail_from")
_config_int(to_save, "mail_size", lambda y: int(y)*1024*1024)
config.save() config.save()
if to_save.get("test"): if to_save.get("test"):

View File

@ -53,7 +53,7 @@ class _Settings(_Base):
mail_login = Column(String, default='mail@example.com') mail_login = Column(String, default='mail@example.com')
mail_password = Column(String, default='mypassword') mail_password = Column(String, default='mypassword')
mail_from = Column(String, default='automailer <mail@example.com>') mail_from = Column(String, default='automailer <mail@example.com>')
mail_size = Column(Integer, default=25) mail_size = Column(Integer, default=25*1024*1024)
config_calibre_dir = Column(String) config_calibre_dir = Column(String)
config_port = Column(Integer, default=constants.DEFAULT_PORT) config_port = Column(Integer, default=constants.DEFAULT_PORT)

View File

@ -145,22 +145,24 @@ def check_send_to_kindle(entry):
if not config.config_converterpath: if not config.config_converterpath:
# no converter - only for mobi and pdf formats # no converter - only for mobi and pdf formats
for ele in iter(entry.data): for ele in iter(entry.data):
if 'MOBI' in ele.format: if ele.uncompressed_size < config.mail_size:
bookformats.append({'format': 'Mobi', if 'MOBI' in ele.format:
'convert': 0, bookformats.append({'format': 'Mobi',
'text': _('Send %(format)s to Kindle', format='Mobi')}) 'convert': 0,
if 'PDF' in ele.format: 'text': _('Send %(format)s to Kindle', format='Mobi')})
bookformats.append({'format': 'Pdf', if 'PDF' in ele.format:
'convert': 0, bookformats.append({'format': 'Pdf',
'text': _('Send %(format)s to Kindle', format='Pdf')}) 'convert': 0,
if 'AZW' in ele.format: 'text': _('Send %(format)s to Kindle', format='Pdf')})
bookformats.append({'format': 'Azw', if 'AZW' in ele.format:
'convert': 0, bookformats.append({'format': 'Azw',
'text': _('Send %(format)s to Kindle', format='Azw')}) 'convert': 0,
'text': _('Send %(format)s to Kindle', format='Azw')})
else: else:
formats = list() formats = list()
for ele in iter(entry.data): for ele in iter(entry.data):
formats.append(ele.format) if ele.uncompressed_size < config.mail_size:
formats.append(ele.format)
if 'MOBI' in formats: if 'MOBI' in formats:
bookformats.append({'format': 'Mobi', bookformats.append({'format': 'Mobi',
'convert': 0, 'convert': 0,

View File

@ -13,7 +13,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mail_port">{{_('SMTP Port')}}</label> <label for="mail_port">{{_('SMTP Port')}}</label>
<input type="number" min="1" max="65535" class="form-control" name="mail_port" id="mail_port" value="{% if config.mail_port != None %}{{ config.mail_port }}{% endif %}" autocomplete="off"> <input type="number" min="1" max="65535" step="1" class="form-control" name="mail_port" id="mail_port" value="{% if content.mail_port != None %}{{ content.mail_port }}{% endif %}" autocomplete="off">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mail_use_ssl">{{_('Encryption')}}</label> <label for="mail_use_ssl">{{_('Encryption')}}</label>
@ -37,9 +37,9 @@
</div> </div>
<label for="mail_size">{{_('Attachment Size Limit')}}</label> <label for="mail_size">{{_('Attachment Size Limit')}}</label>
<div class="form-group input-group"> <div class="form-group input-group">
<input type="number" min="1" max="600" class="form-control" name="attachment_size" id="mail_size" value="{% if config.mail_size != None %}{{ config.mail_size }}{% endif %}"> <input type="number" min="1" max="600" step="1" class="form-control" name="mail_size" id="mail_size" value="{% if content.mail_size != None %}{{ (content.mail_size / 1024 / 1024)|int }}{% endif %}">
<span class="input-group-btn"> <span class="input-group-btn">
<button type="button" id="certfile_path" class="btn btn-default" disabled>MB</button> <button type="button" id="attachement_size" class="btn btn-default" disabled>MB</button>
</span> </span>
</div> </div>
<button type="submit" name="submit" value="submit" class="btn btn-default">{{_('Save')}}</button> <button type="submit" name="submit" value="submit" class="btn btn-default">{{_('Save')}}</button>