From ad3300f45addf4a36cf9301e0720cf425031a60a Mon Sep 17 00:00:00 2001 From: VITAS Date: Sat, 8 Apr 2023 09:59:34 +0200 Subject: [PATCH 01/12] Display all activated Games in overview --- templates/index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index 194e3cc0..b0eacedb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,9 +34,7 @@

Games

{%- for game in games -%} - {%- if game.mod_count() > 0 -%} {% include "game-box.html" %} - {%- endif -%} {%- endfor -%}
From 4d308781a659e95d9f45365d33d3f9443e9baee9 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 8 Apr 2023 18:28:20 -0500 Subject: [PATCH 02/12] Fix admin user deletion on profile --- KerbalStuff/blueprints/api.py | 2 +- frontend/coffee/profile.coffee | 24 ++++++++++++++++++++---- templates/view_profile.html | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/KerbalStuff/blueprints/api.py b/KerbalStuff/blueprints/api.py index 70b134e3..e24d53ba 100644 --- a/KerbalStuff/blueprints/api.py +++ b/KerbalStuff/blueprints/api.py @@ -592,7 +592,7 @@ def delete(username: str) -> Tuple[Dict[str, Any], int]: if user == current_user: logout_user() - return {"error": False}, 400 + return {"error": False}, 200 @api.route('/api/mod//update-bg', methods=['POST']) diff --git a/frontend/coffee/profile.coffee b/frontend/coffee/profile.coffee index 900bf878..b7cc2998 100644 --- a/frontend/coffee/profile.coffee +++ b/frontend/coffee/profile.coffee @@ -1,5 +1,6 @@ -editor = new Editor() -editor.render() +if $('textarea').length + editor = new Editor() + editor.render() # Background Uploading window.upload_bg = (files, box) -> @@ -138,6 +139,21 @@ $('#delete-account-form').submit((e) -> xhr.send(form) ) +$('#confirm-delete-account').on 'show.bs.modal', (evt) -> + # Disable final Delete button on modal open + $(evt.target).find('input[type=submit]').prop('disabled', true) + # Clear username confirmation text box on modal open + $(evt.target).find('input[type=text]').val('') + +$('#confirm-delete-account').on 'shown.bs.modal', (evt) -> + # Focus text box on modal open + $(evt.target).find('input[type=text]').focus() + +$('#username').on 'input', (evt) -> + # Enable/disable final Delete button on confirmation text box change + $('#confirm-delete-account').find('input[type=submit]').prop('disabled', + evt.target.value != evt.target.dataset.username) + deleteAccountModalDialog = () -> $('#delete-account-form').trigger('reset') error_message_display = $('#delete-account-error-message') @@ -150,7 +166,7 @@ deleteAccountModalDialog = () -> for button in buttons button.removeAttribute('disabled') -$('#delete-account').on('hidden.bs.modal', deleteAccountModalDialog) +$('#confirm-delete-account').on('hidden.bs.modal', deleteAccountModalDialog) $('#check-all-updates' ).on('click', () -> $('[id^=updates-]' ).prop('checked', true)) $('#uncheck-all-updates' ).on('click', () -> $('[id^=updates-]' ).prop('checked', false)) @@ -171,4 +187,4 @@ $('#save-changes').on 'click', () -> $('#overall-error').hide() else $('#overall-error').show() - return allValid \ No newline at end of file + return allValid diff --git a/templates/view_profile.html b/templates/view_profile.html index ae08db8b..33acb899 100644 --- a/templates/view_profile.html +++ b/templates/view_profile.html @@ -252,7 +252,7 @@
+ name="username" data-username="{{profile.username}}">
From 622731ec485473a4d02761ebfd78a82b1ab1990c Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 8 Apr 2023 17:54:30 -0500 Subject: [PATCH 04/12] Show add-mod button instead of empty game sections --- KerbalStuff/blueprints/anonymous.py | 4 +++- templates/game.html | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/KerbalStuff/blueprints/anonymous.py b/KerbalStuff/blueprints/anonymous.py index d6157b6b..ccba6435 100644 --- a/KerbalStuff/blueprints/anonymous.py +++ b/KerbalStuff/blueprints/anonymous.py @@ -9,7 +9,7 @@ get_featured_mods, get_top_mods, get_new_mods, get_updated_mods, sendfile from ..config import _cfg from ..database import db -from ..objects import Featured, Mod, ModVersion, User +from ..objects import Featured, Mod, ModVersion, User, ModList from ..search import apply_search_to_query anonymous = Blueprint('anonymous', __name__) @@ -29,6 +29,7 @@ def game(gameshort: str) -> str: recent = get_updated_mods(ga.id, 6) user_count = User.query.count() mod_count = ga.mod_count() + pack_count = ModList.query.filter(ModList.game_id == ga.id, ModList.mods.any()).count() following = sorted(filter(lambda m: m.game_id == ga.id, current_user.following), key=lambda m: m.updated, reverse=True)[:6] if current_user else list() return render_template("game.html", @@ -41,6 +42,7 @@ def game(gameshort: str) -> str: recent=recent, user_count=user_count, mod_count=mod_count, + pack_count=pack_count, yours=following) diff --git a/templates/game.html b/templates/game.html index 8047aa07..3146cc63 100644 --- a/templates/game.html +++ b/templates/game.html @@ -28,6 +28,7 @@
{%- endif -%} +{% if mod_count > 0 %} {% if user and len(yours) >= 1 %}
@@ -112,6 +113,7 @@

Most Popular

{% endfor %}
+{% if pack_count > 0 %}
@@ -122,6 +124,23 @@

Most Popular

+{% endif %} +{% else %} +
+
+
+
+ There are no mods for {{ga.name}} yet. +
+
+ +
+
+{% endif %} {% endblock %} {% block scripts %}