aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/tasks/forumtasks.py19
-rw-r--r--app/templates/admin/list.html1
-rw-r--r--app/templates/users/user_profile_page.html4
-rw-r--r--app/views/admin.py5
4 files changed, 24 insertions, 5 deletions
diff --git a/app/tasks/forumtasks.py b/app/tasks/forumtasks.py
index 0a5f028..9e4cbfb 100644
--- a/app/tasks/forumtasks.py
+++ b/app/tasks/forumtasks.py
@@ -25,7 +25,8 @@ import urllib.request
from urllib.parse import urlparse, quote_plus
@celery.task()
-def checkForumAccount(username):
+def checkForumAccount(username, forceNoSave=False):
+ print("Checking " + username)
try:
profile = getProfile("https://forum.minetest.net", username)
except OSError:
@@ -52,9 +53,23 @@ def checkForumAccount(username):
user.profile_pic = pic
# Save
- if needsSaving:
+ if needsSaving and not forceNoSave:
db.session.commit()
+ return needsSaving
+
+@celery.task()
+def checkAllForumAccounts(forceNoSave=False):
+ needsSaving = False
+ query = User.query.filter(User.forums_username.isnot(None))
+ for user in query.all():
+ needsSaving = checkForumAccount(user.username) or needsSaving
+
+ if needsSaving and not forceNoSave:
+ db.session.commit()
+
+ return needsSaving
+
regex_tag = re.compile(r"\[([a-z0-9_]+)\]")
BANNED_NAMES = ["mod", "game", "old", "outdated", "wip", "api", "beta", "alpha", "git"]
diff --git a/app/templates/admin/list.html b/app/templates/admin/list.html
index 5237304..d4e4da6 100644
--- a/app/templates/admin/list.html
+++ b/app/templates/admin/list.html
@@ -20,6 +20,7 @@
<select name="action">
<option value="importmodlist" selected>Import forum topics</option>
<option value="recalcscores">Recalculate package scores</option>
+ <option value="checkusers">Check forum users</option>
<option value="importscreenshots">Import screenshots from VCS</option>
<!-- <option value="importdepends">Import dependencies from downloads</option> -->
<!-- <option value="modprovides">Set provides to mod name</option> -->
diff --git a/app/templates/users/user_profile_page.html b/app/templates/users/user_profile_page.html
index 26988ba..cdb9ad1 100644
--- a/app/templates/users/user_profile_page.html
+++ b/app/templates/users/user_profile_page.html
@@ -139,7 +139,7 @@
{% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(packages, show_author=False) }}
-{% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(UserRank.EDITOR)) %}
+{% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.EDITOR)) %}
<div class="card mt-3">
<a name="unadded-topics"></a>
<h2 class="card-header">Unadded topics</h2>
@@ -153,7 +153,7 @@
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }}
{% else %}
- <p>Congrats! You don't have any topics which aren't on CDB.</p>
+ <p class="card-body">Congrats! You don't have any topics which aren't on CDB.</p>
{% endif %}
</div>
{% endif %}
diff --git a/app/views/admin.py b/app/views/admin.py
index d370b69..b2b615d 100644
--- a/app/views/admin.py
+++ b/app/views/admin.py
@@ -22,7 +22,7 @@ from app import app
from app.models import *
from celery import uuid
from app.tasks.importtasks import importRepoScreenshot, importAllDependencies, makeVCSRelease
-from app.tasks.forumtasks import importTopicList
+from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
from flask_wtf import FlaskForm
from wtforms import *
from app.utils import loginUser, rank_required, triggerNotif
@@ -36,6 +36,9 @@ def admin_page():
if action == "importmodlist":
task = importTopicList.delay()
return redirect(url_for("check_task", id=task.id, r=url_for("todo_topics_page")))
+ elif action == "checkusers":
+ task = checkAllForumAccounts.delay()
+ return redirect(url_for("check_task", id=task.id, r=url_for("admin_page")))
elif action == "importscreenshots":
packages = Package.query \
.filter_by(soft_deleted=False) \