diff --git a/cps/helper.py b/cps/helper.py index f4c226a6..a1d28275 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -117,9 +117,11 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format, # Texts are not lazy translated as they are supposed to get send out as is def send_test_mail(ereader_mail, user_name): - WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email'), None, None, - config.get_mail_settings(), ereader_mail, N_("Test Email"), - _('This Email has been sent via Calibre-Web.'))) + for email in ereader_mail.split(','): + email = email.strip() + WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email', None, None, + config.get_mail_settings(), email, N_("Test Email"), + _('This Email has been sent via Calibre-Web.')))) return @@ -225,9 +227,11 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id) converted_file_name = entry.name + '.' + book_format.lower() link = '{}'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) email_text = N_("%(book)s send to eReader", book=link) - WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, - config.get_mail_settings(), ereader_mail, - email_text, _('This Email has been sent via Calibre-Web.'), book.id)) + for email in ereader_mail.split(','): + email = email.strip() + WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, + config.get_mail_settings(), email, + email_text, _('This Email has been sent via Calibre-Web.'), book.id)) return return _("The requested file could not be read. Maybe wrong permissions?") @@ -691,15 +695,16 @@ def check_username(username): return username -def valid_email(email): - email = email.strip() - # if email is not deleted - if email: - # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation - if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", - email): - log.error("Invalid Email address format") - raise Exception(_("Invalid Email address format")) +def valid_email(emails): + for email in emails.split(','): + email = email.strip() + # if email is not deleted + if email: + # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation + if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", + email): + log.error("Invalid Email address format") + raise Exception(_("Invalid Email address format")) return email diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index 868839ab..5354dce2 100644 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -105,17 +105,19 @@ class TaskConvert(CalibreTask): # if we're sending to E-Reader after converting, create a one-off task and run it immediately # todo: figure out how to incorporate this into the progress try: - EmailText = N_("%(book)s send to E-Reader", book=escape(self.title)) - worker_thread.add(self.user, TaskEmail(self.settings['subject'], - self.results["path"], - filename, - self.settings, - self.ereader_mail, - EmailText, - self.settings['body'], - id=self.book_id, - internal=True) - ) + EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title)) + for email in self.ereader_mail.split(','): + email = email.strip() + worker_thread.add(self.user, TaskEmail(self.settings['subject'], + self.results["path"], + filename, + self.settings, + email, + EmailText, + self.settings['body'], + id=self.book_id, + internal=True) + ) except Exception as ex: return self._handleError(str(ex)) diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 1bee1c1d..ff1c3687 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -62,13 +62,13 @@ {% if g.current_theme == 1 %} @@ -91,9 +91,9 @@
  • {% endif %} {% if g.current_theme == 0 %} -
  • +
  • {% if not current_user.is_anonymous %} -
  • +
  • {% endif %} {% endif %} {% endif %} diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index a3ead445..bbb7a70d 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -25,7 +25,7 @@ {% endif %}
    - +
    {% if not content.role_anonymous() %} diff --git a/cps/web.py b/cps/web.py index 3e0fce9a..b53fe421 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1451,7 +1451,14 @@ def logout(): if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): logout_oauth_user() log.debug("User logged out") - return redirect(url_for('web.login')) + if config.config_anonbrowse: + location = get_redirect_location(request.args.get('next', None), "web.login") + else: + location = None + if location: + return redirect(location) + else: + return redirect(url_for('web.login')) # ################################### Users own configuration ######################################################### diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 952b4f89..5a75ea1c 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
    -

    Start Time: 2024-07-02 20:54:09

    +

    Start Time: 2024-07-08 03:05:56

    -

    Stop Time: 2024-07-03 04:18:18

    +

    Stop Time: 2024-07-08 05:05:40

    -

    Duration: 6h 10 min

    +

    Duration: 54:3 min

    @@ -234,12 +234,12 @@ - + TestBackupMetadata 21 - 20 - 1 - 0 + 8 + 3 + 10 0 Detail @@ -265,8 +265,8 @@
    Traceback (most recent call last):
    -  File "/home/ozzie/Development/calibre-web-test/test/test_backup_metadata.py", line 54, in test_backup_all
    -    self.assertEqual(1, len(res))
    +  File "/home/ozzie/Development/calibre-web-test/test/test_backup_metadata.py", line 83, in test_backup_all
    +    self.assertEqual(1, len(tasks))
     AssertionError: 1 != 0
    @@ -286,11 +286,43 @@ AssertionError: 1 != 0 - +
    TestBackupMetadata - test_backup_change_book_description
    - PASS + +
    + FAIL +
    + + + + @@ -304,11 +336,38 @@ AssertionError: 1 != 0 - +
    TestBackupMetadata - test_backup_change_book_language
    - PASS + +
    + FAIL +
    + + + + @@ -331,11 +390,31 @@ AssertionError: 1 != 0 - +
    TestBackupMetadata - test_backup_change_book_rating
    - PASS + +
    + ERROR +
    + + + + @@ -367,83 +446,263 @@ AssertionError: 1 != 0 - +
    TestBackupMetadata - test_backup_change_custom_Comment
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_Enum
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_bool
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_categories
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_date
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_float
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_int
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_rating
    - PASS + +
    + ERROR +
    + + + + - +
    TestBackupMetadata - test_backup_change_custom_text
    - PASS + +
    + ERROR +
    + + + + @@ -458,13 +717,13 @@ AssertionError: 1 != 0 - + TestBackupMetadataGdrive 1 + 0 + 0 1 0 - 0 - 0 Detail @@ -472,153 +731,2969 @@ AssertionError: 1 != 0 - +
    TestBackupMetadataGdrive - test_backup_gdrive
    - PASS + +
    + ERROR +
    + + + + - - TestCli - 13 - 13 + + _ErrorHolder + 45 0 0 + 45 0 - Detail + Detail - + -
    TestCli - test_already_started
    +
    tearDownClass (test_backup_metadata_gdrive)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_bind_to_single_interface
    +
    setUpClass (test_cli)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_change_password
    +
    tearDownClass (test_cover_edit_books)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_cli_SSL_files
    +
    tearDownClass (test_delete_database)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_cli_different_folder
    +
    tearDownClass (test_ebook_convert)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_cli_different_settings_database
    +
    tearDownClass (test_edit_additional_books)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_dryrun_update
    +
    tearDownClass (test_edit_books)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_enable_reconnect
    +
    tearDownClass (test_edit_books_author)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_environ_port_setting
    +
    tearDownClass (test_edit_books_author_gdrive)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_logfile
    +
    tearDownClass (test_edit_books_list)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_no_database
    +
    tearDownClass (test_edit_books_metadata)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_settingsdb_not_writeable
    +
    tearDownClass (test_edit_metadata_scholar)
    + + +
    + ERROR +
    + + + - PASS - + -
    TestCli - test_writeonly_static_files
    +
    tearDownClass (test_email_STARTTLS)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_email_ssl)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_embed_metadata)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_error_book)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_error_read_column)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_goodreads)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_kobo_sync)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_kobo_sync_big)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_limiter)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_list_orders)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_logging)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_login)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_merge_books_list)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_oauth)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_opds_feed)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_pdf_metadata)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_pip_install)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_reader)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_readonly_db)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_register)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_reverse_proxy)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_shelf)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_socket)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_split_library)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_systemd_activation)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_thumbnail_env)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_thumbnails)
    + + +
    + ERROR +
    + + + + + + + + + + +
    setUpClass (test_updater)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_upload_epubs)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_user_list)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_user_load)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_user_template)
    + + +
    + ERROR +
    + + + + + + + + + + +
    tearDownClass (test_visiblilitys)
    + + +
    + ERROR +
    + + + - PASS - + TestCliGdrivedb 4 - 4 0 + 4 0 0 @@ -628,282 +3703,26 @@ AssertionError: 1 != 0 - +
    TestCliGdrivedb - test_cli_gdrive_folder
    - PASS - - - - - - -
    TestCliGdrivedb - test_cli_gdrive_location
    - - PASS - - - - - - -
    TestCliGdrivedb - test_gdrive_db_nonwrite
    - - PASS - - - - - - -
    TestCliGdrivedb - test_no_database
    - - PASS - - - - - - - TestCoverEditBooks - 2 - 2 - 0 - 0 - 0 - - Detail - - - - - - - -
    TestCoverEditBooks - test_invalid_jpg_hdd
    - - PASS - - - - - - -
    TestCoverEditBooks - test_upload_jpg
    - - PASS - - - - - - - TestDeleteDatabase - 1 - 1 - 0 - 0 - 0 - - Detail - - - - - - - -
    TestDeleteDatabase - test_delete_books_in_database
    - - PASS - - - - - - - TestEbookConvertCalibre - 15 - 15 - 0 - 0 - 0 - - Detail - - - - - - - -
    TestEbookConvertCalibre - test_calibre_log
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_deactivate
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_email
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_failed_and_email
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_only
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_options
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_parameter
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_wrong_excecutable
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_convert_xss
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_email_failed
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_email_only
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_kindle_send_not_configured
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_ssl_smtp_setup_error
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_starttls_smtp_setup_error
    - - PASS - - - - - - -
    TestEbookConvertCalibre - test_user_convert_xss
    - - PASS - - - - - - - TestEbookConvertCalibreGDrive - 7 - 5 - 1 - 1 - 0 - - Detail - - - - - - - -
    TestEbookConvertCalibreGDrive - test_convert_email
    -
    - FAIL + FAIL
    -