mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Readd "Sync with Forums" button to profile picture settings
This commit is contained in:
parent
459eb02112
commit
8dfd5c407d
@ -22,8 +22,10 @@ from flask_babel import gettext
|
||||
from flask_login import current_user, login_required
|
||||
from sqlalchemy import func, text
|
||||
|
||||
from app.models import User, db, Package, PackageReview, PackageState, PackageType
|
||||
from app.models import User, db, Package, PackageReview, PackageState, PackageType, UserRank
|
||||
from app.utils import get_daterange_options
|
||||
from app.tasks.forumtasks import check_forum_account
|
||||
|
||||
from . import bp
|
||||
|
||||
|
||||
@ -235,6 +237,25 @@ def profile(username):
|
||||
medals_unlocked=unlocked, medals_locked=locked)
|
||||
|
||||
|
||||
@bp.route("/users/<username>/check-forums/", methods=["POST"])
|
||||
@login_required
|
||||
def user_check_forums(username):
|
||||
user = User.query.filter_by(username=username).first()
|
||||
if user is None:
|
||||
abort(404)
|
||||
|
||||
if current_user != user and not current_user.rank.atLeast(UserRank.MODERATOR):
|
||||
abort(403)
|
||||
|
||||
if user.forums_username is None:
|
||||
abort(404)
|
||||
|
||||
task = check_forum_account.delay(user.forums_username, force_replace_pic=True)
|
||||
next_url = url_for("users.profile", username=username)
|
||||
|
||||
return redirect(url_for("tasks.check", id=task.id, r=next_url))
|
||||
|
||||
|
||||
@bp.route("/user/stats/")
|
||||
@login_required
|
||||
def statistics_redirect():
|
||||
|
@ -28,7 +28,7 @@ from .usertasks import set_profile_picture_from_url
|
||||
|
||||
|
||||
@celery.task()
|
||||
def check_forum_account(forums_username):
|
||||
def check_forum_account(forums_username, force_replace_pic=False):
|
||||
print("### Checking " + forums_username, file=sys.stderr)
|
||||
try:
|
||||
profile = get_profile("https://forum.minetest.net", forums_username)
|
||||
@ -69,7 +69,7 @@ def check_forum_account(forums_username):
|
||||
print(f"####### User pp {user.profile_pic}", file=sys.stderr)
|
||||
|
||||
pic_needs_replacing = user.profile_pic is None or user.profile_pic == "" or \
|
||||
user.profile_pic.startswith("https://forum.minetest.net")
|
||||
user.profile_pic.startswith("https://forum.minetest.net") or force_replace_pic
|
||||
if pic_needs_replacing and pic.startswith("https://forum.minetest.net"):
|
||||
print(f"####### Queueing", file=sys.stderr)
|
||||
set_profile_picture_from_url.delay(user.username, pic)
|
||||
|
@ -21,7 +21,14 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col">
|
||||
{% if user.email %}
|
||||
{% if user.forums_username %}
|
||||
<form method="post" action="{{ url_for('users.user_check_forums', username=user.username) }}" class="" style="display:inline-block;">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="submit" class="btn btn-primary" value="{{ _('Sync with Forums') }}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if user.profile_pic %}
|
||||
{% elif user.email %}
|
||||
<a class="btn btn-primary" href="https://en.gravatar.com/">
|
||||
Gravatar
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user