From 39ca00cb8e22a88abcfdf2504ec479cb3ffe4c37 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:09:46 +1300 Subject: [PATCH] bug fixes and tweaks after initial user testing --- ROADMAP.md | 6 ++-- app/admin/routes.py | 18 ++++++----- app/auth/routes.py | 2 +- app/community/routes.py | 10 +++---- app/main/routes.py | 7 +++-- app/static/js/scripts.js | 9 ++++++ app/static/styles.css | 1 + app/static/styles.scss | 1 + app/templates/base.html | 2 +- app/templates/community/add_post.html | 17 +++++++++-- app/templates/community/add_remote.html | 4 +-- app/templates/community/community.html | 4 +-- app/templates/email/reset_password.html | 1 + app/templates/email/verification.html | 1 + app/templates/email/welcome.html | 2 +- app/templates/errors/404.html | 2 +- app/templates/errors/500.html | 4 +-- app/templates/index.html | 2 +- app/templates/list_communities.html | 33 +++++++++++---------- app/templates/post/_post_full.html | 12 ++++---- app/templates/post/add_reply.html | 4 +-- app/templates/post/continue_discussion.html | 4 +-- app/templates/post/post.html | 4 +-- app/templates/user/notifications.html | 2 +- app/templates/user/show_profile.html | 14 +++++---- app/user/forms.py | 2 +- app/user/routes.py | 18 ++++++----- 27 files changed, 112 insertions(+), 74 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 107247ff..78801ce0 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -5,11 +5,11 @@ The following are the goals for a 1.0 release, good enough for production use. I ### Basic functionality - ✅ log in, register, reset password -- ✅ browse and subscribe to communities +- ✅ browse and join communities - ✅ post in local community - ✅ comment on posts in local community - ✅ vote -- sort posts by hotness algo +- ✅ sort posts by hotness algo - ✅ markdown - ✅ logging and debugging support @@ -30,7 +30,7 @@ The following are the goals for a 1.0 release, good enough for production use. I ### Moderation - community moderation -- blocking - users, communities, domains, instances. bi-directional. +- ✅ blocking - users, communities, domains, instances. bi-directional. - import/export of block lists ### Onboarding diff --git a/app/admin/routes.py b/app/admin/routes.py index 44c21c7f..bf10ce37 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -385,10 +385,11 @@ def admin_user_edit(user_id): profile_file = request.files['profile_file'] if profile_file and profile_file.filename != '': # remove old avatar - file = File.query.get(user.avatar_id) - file.delete_from_disk() - user.avatar_id = None - db.session.delete(file) + if user.avatar_id: + file = File.query.get(user.avatar_id) + file.delete_from_disk() + user.avatar_id = None + db.session.delete(file) # add new avatar file = save_icon_file(profile_file, 'users') @@ -397,10 +398,11 @@ def admin_user_edit(user_id): banner_file = request.files['banner_file'] if banner_file and banner_file.filename != '': # remove old cover - file = File.query.get(user.cover_id) - file.delete_from_disk() - user.cover_id = None - db.session.delete(file) + if user.cover_id: + file = File.query.get(user.cover_id) + file.delete_from_disk() + user.cover_id = None + db.session.delete(file) # add new cover file = save_banner_file(banner_file, 'users') diff --git a/app/auth/routes.py b/app/auth/routes.py index 9d49573d..5084cb03 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -104,7 +104,7 @@ def register(): if current_app.config['MODE'] == 'development': current_app.logger.info('Verify account:' + url_for('auth.verify_email', token=user.verification_token, _external=True)) - flash(_('Great, you are now a registered user! Choose some communities to subscribe to. Use the topic filter to narrow things down.')) + flash(_('Great, you are now a registered user! Choose some communities to join. Use the topic filter to narrow things down.')) resp = make_response(redirect(url_for('main.list_communities'))) if user_ip_banned(): diff --git a/app/community/routes.py b/app/community/routes.py index 7079093e..6606ce76 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -222,9 +222,9 @@ def subscribe(actor): success = post_request(community.ap_inbox_url, follow, current_user.private_key, current_user.profile_id() + '#main-key') if success: - flash('Your request to subscribe has been sent to ' + community.title) + flash('Your request to join has been sent to ' + community.title) else: - flash('There was a problem while trying to subscribe.', 'error') + flash('There was a problem while trying to join.', 'error') else: # for local communities, joining is instant banned = CommunityBan.query.filter_by(user_id=current_user.id, community_id=community.id).first() if banned: @@ -232,7 +232,7 @@ def subscribe(actor): member = CommunityMember(user_id=current_user.id, community_id=community.id) db.session.add(member) db.session.commit() - flash('You are subscribed to ' + community.title) + flash('You joined ' + community.title) referrer = request.headers.get('Referer', None) if referrer is not None: return redirect(referrer) @@ -278,14 +278,14 @@ def unsubscribe(actor): activity.result = 'success' db.session.commit() if not success: - flash('There was a problem while trying to subscribe', 'error') + flash('There was a problem while trying to join', 'error') if proceed: db.session.query(CommunityMember).filter_by(user_id=current_user.id, community_id=community.id).delete() db.session.query(CommunityJoinRequest).filter_by(user_id=current_user.id, community_id=community.id).delete() db.session.commit() - flash('You are unsubscribed from ' + community.title) + flash('You are left ' + community.title) cache.delete_memoized(community_membership, current_user, community) else: diff --git a/app/main/routes.py b/app/main/routes.py index 4f49b2c5..030d1e0d 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -163,8 +163,11 @@ def list_local_communities(): @bp.route('/communities/subscribed', methods=['GET']) def list_subscribed_communities(): verification_warning() - communities = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == current_user.id).all() - return render_template('list_communities.html', communities=communities, title=_('Subscribed communities'), + if current_user.is_authenticated: + communities = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == current_user.id).all() + else: + communities = [] + return render_template('list_communities.html', communities=communities, title=_('Joined communities'), SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER) diff --git a/app/static/js/scripts.js b/app/static/js/scripts.js index f5ae68a8..bf37ada2 100644 --- a/app/static/js/scripts.js +++ b/app/static/js/scripts.js @@ -87,6 +87,15 @@ function setupConfirmFirst() { event.preventDefault(); // As the user clicked "Cancel" in the dialog, prevent the default action. } }); + }); + + const go_back = document.querySelectorAll('.go_back'); + go_back.forEach(element => { + element.addEventListener("click", function(event) { + history.back(); + event.preventDefault(); + return false; + }); }) } diff --git a/app/static/styles.css b/app/static/styles.css index 71c67130..2b39f51d 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -454,6 +454,7 @@ nav.navbar { max-height: 30px; min-width: 20px; min-height: 20px; + vertical-align: text-top; } .community_icon_big { diff --git a/app/static/styles.scss b/app/static/styles.scss index f92e45c7..15a97f11 100644 --- a/app/static/styles.scss +++ b/app/static/styles.scss @@ -120,6 +120,7 @@ nav.navbar { max-height: 30px; min-width: 20px; min-height: 20px; + vertical-align: text-top; } .community_icon_big { diff --git a/app/templates/base.html b/app/templates/base.html index 415da616..8051e75b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -73,7 +73,7 @@ {% block navbar %}