diff --git a/moments/blueprints/auth.py b/moments/blueprints/auth.py index e37aca5..0a0506d 100644 --- a/moments/blueprints/auth.py +++ b/moments/blueprints/auth.py @@ -71,8 +71,8 @@ def register(): login_user(user) token = generate_token(user=user, operation=Operations.CONFIRM) send_confirmation_email(user=user, token=token) - flash('Confirm email sent, check your inbox.', 'info') - return redirect(url_for('main.index')) + flash('Confirmation email sent, please check your inbox.', 'info') + return redirect(url_for('.login')) return render_template('auth/register.html', form=form) @@ -100,7 +100,7 @@ def resend_confirmation_email(): token = generate_token(user=current_user, operation=Operations.CONFIRM) send_confirmation_email(user=current_user, token=token) - flash('New email sent, check your inbox.', 'info') + flash('New email sent, please check your inbox.', 'info') return redirect(url_for('main.index')) @@ -116,7 +116,7 @@ def forget_password(): if user: token = generate_token(user=user, operation=Operations.RESET_PASSWORD) send_reset_password_email(user=user, token=token) - flash('Password reset email sent, check your inbox.', 'info') + flash('Password reset email sent, please check your inbox.', 'info') return redirect(url_for('.login')) flash('Invalid email.', 'warning') return redirect(url_for('.forget_password')) diff --git a/moments/blueprints/user.py b/moments/blueprints/user.py index ec3499b..4355da7 100644 --- a/moments/blueprints/user.py +++ b/moments/blueprints/user.py @@ -191,7 +191,7 @@ def change_email_request(): if form.validate_on_submit(): token = generate_token(user=current_user, operation=Operations.CHANGE_EMAIL, new_email=form.email.data.lower()) send_change_email_email(to=form.email.data, user=current_user, token=token) - flash('Confirm email sent, check your inbox.', 'info') + flash('Confirmation email sent, please check your inbox.', 'info') return redirect(url_for('.index', username=current_user.username)) return render_template('user/settings/change_email.html', form=form) diff --git a/moments/static/js/main.js b/moments/static/js/main.js index 5ea9c83..5295d77 100644 --- a/moments/static/js/main.js +++ b/moments/static/js/main.js @@ -12,16 +12,16 @@ document.addEventListener('DOMContentLoaded', () => { } function toast(message, category) { - const toastElem = document.getElementById('mainToast') - const toast = bootstrap.Toast.getOrCreateInstance(toastElem) - toastElem.querySelector('.toast-body').textContent = message + const toastElem = document.getElementById('mainToast'); + const toast = bootstrap.Toast.getOrCreateInstance(toastElem); + toastElem.querySelector('.toast-body').textContent = message; if (category === 'error') { - toastElem.classList.replace('text-bg-secondary', 'text-bg-danger') + toastElem.classList.replace('text-bg-secondary', 'text-bg-danger'); } else { - toastElem.classList.replace('text-bg-danger', 'text-bg-secondary') + toastElem.classList.replace('text-bg-danger', 'text-bg-secondary'); } - toast.show() + toast.show(); } function showProfilePopover(event) { @@ -36,7 +36,7 @@ document.addEventListener('DOMContentLoaded', () => { content: data, html: true, sanitize: false, - trigger: 'manual' + trigger: 'manual', }); popover.setContent({ '.popover-body': data @@ -48,9 +48,7 @@ document.addEventListener('DOMContentLoaded', () => { }, 200); }); }) - .catch(error => { - handleFetchError(error); - }); + .catch(handleFetchError); }, 500); } @@ -120,7 +118,7 @@ document.addEventListener('DOMContentLoaded', () => { fetch(elem.dataset.href, { method: 'POST', headers: { - 'X-CSRFToken': csrfToken + 'X-CSRFToken': csrfToken, } }) .then(response => response.json()) @@ -139,7 +137,7 @@ document.addEventListener('DOMContentLoaded', () => { fetch(elem.dataset.href, { method: 'POST', headers: { - 'X-CSRFToken': csrfToken + 'X-CSRFToken': csrfToken, } }) .then(response => response.json()) @@ -161,7 +159,7 @@ document.addEventListener('DOMContentLoaded', () => { fetch(elem.dataset.href, { method: 'POST', headers: { - 'X-CSRFToken': csrfToken + 'X-CSRFToken': csrfToken, } }) .then(response => response.json()) @@ -183,7 +181,7 @@ document.addEventListener('DOMContentLoaded', () => { fetch(elem.dataset.href, { method: 'POST', headers: { - 'X-CSRFToken': csrfToken + 'X-CSRFToken': csrfToken, } }) .then(response => response.json()) @@ -202,26 +200,26 @@ document.addEventListener('DOMContentLoaded', () => { function renderAllDatetime() { // render normal time - const elements = document.querySelectorAll('.dayjs') + const elements = document.querySelectorAll('.dayjs'); elements.forEach(elem => { - const date = dayjs.utc(elem.innerHTML) - const format = elem.dataset.format ?? 'LL' - elem.innerHTML = date.local().format(format) - }) + const date = dayjs.utc(elem.innerHTML); + const format = elem.dataset.format ?? 'LL'; + elem.innerHTML = date.local().format(format); + }); // render from now time - const fromNowElements = document.querySelectorAll('.dayjs-from-now') + const fromNowElements = document.querySelectorAll('.dayjs-from-now'); fromNowElements.forEach(elem => { - const date = dayjs.utc(elem.innerHTML) - elem.innerHTML = date.local().fromNow() - }) + const date = dayjs.utc(elem.innerHTML); + elem.innerHTML = date.local().fromNow(); + }); // render tooltip time - const toolTipElements = document.querySelectorAll('.dayjs-tooltip') + const toolTipElements = document.querySelectorAll('.dayjs-tooltip'); toolTipElements.forEach(elem => { - const date = dayjs.utc(elem.dataset.timestamp) - const format = elem.dataset.format ?? 'LLL' - elem.dataset.bsTitle = date.local().format(format) - const tooltip = new bootstrap.Tooltip(elem) - }) + const date = dayjs.utc(elem.dataset.timestamp); + const format = elem.dataset.format ?? 'LLL'; + elem.dataset.bsTitle = date.local().format(format); + const tooltip = new bootstrap.Tooltip(elem); + }); } document.addEventListener('click', event => { @@ -290,10 +288,10 @@ document.addEventListener('DOMContentLoaded', () => { setInterval(updateNotificationsCount, 30000); } - const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) + const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); const tooltipList = tooltipTriggerList.map(tooltipTriggerElem => { - return new bootstrap.Tooltip(tooltipTriggerElem) + return new bootstrap.Tooltip(tooltipTriggerElem); }); - renderAllDatetime() + renderAllDatetime(); }); diff --git a/moments/utils.py b/moments/utils.py index 9413853..b3dd5e6 100644 --- a/moments/utils.py +++ b/moments/utils.py @@ -48,7 +48,7 @@ def resize_image(image, filename, base_width): def validate_image(filename): - ext = Path(filename).suffix + ext = Path(filename).suffix.lower() allowed_extensions = current_app.config['DROPZONE_ALLOWED_FILE_TYPE'].split(',') return '.' in filename and ext in allowed_extensions diff --git a/tests/test_auth.py b/tests/test_auth.py index 5e0fa23..19e936b 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -57,7 +57,7 @@ def test_register_account(self): follow_redirects=True, ) data = response.get_data(as_text=True) - self.assertIn('Confirm email sent, check your inbox.', data) + self.assertIn('Confirmation email sent, please check your inbox.', data) def test_confirm_account(self): user = User.query.filter_by(email='unconfirmed@helloflask.com').first() @@ -85,7 +85,7 @@ def test_reset_password(self): follow_redirects=True, ) data = response.get_data(as_text=True) - self.assertIn('Password reset email sent, check your inbox.', data) + self.assertIn('Password reset email sent, please check your inbox.', data) user = User.query.filter_by(email='normal@helloflask.com').first() self.assertTrue(user.validate_password('123'))