", methods=["GET", "POST"])
+def user(id):
+ if "token" not in session or not Session.verify_session(session["token"], request.remote_addr):
+ # New or invalid session, send to login
+ return redirect(url_for('alogin.login'))
+
+ if User.get_permission_token(session["token"], "solder_users") == 0:
+ return redirect(request.referrer)
+
+ try:
+ packs = User_modpack.get_all_user_modpacks(id)
+ except connector.ProgrammingError as e:
+ Database.create_tables()
+ packs = []
+ flash("error when getting user modpack list", "error")
+
+ user_perms = User_modpack.get_user_permission(id)
+
+ if request.method == "POST":
+ if "form-submit" in request.form:
+ if "modpack" not in request.form:
+ return redirect(id)
+ User_modpack.new(id, request.form["modpack"])
+ return redirect(id)
+ if "form2-submit" in request.form:
+ if "delete_id" not in request.form:
+ return redirect(id)
+ User_modpack.delete_user_modpack(request.form["delete_id"])
+ return redirect(id)
+ if "perm-submit" in request.form:
+ solder_full = "0"
+ solder_users = "0"
+ solder_keys = "0"
+ solder_clients = "0"
+ solder_env = "0"
+ mods_create = "0"
+ mods_manage = "0"
+ mods_delete = "0"
+ modpacks_create = "0"
+ modpacks_manage = "0"
+ modpacks_delete = "0"
+ if "solder_full" in request.form:
+ solder_full = request.form['solder_full']
+ if "solder_users" in request.form:
+ solder_users = request.form['solder_users']
+ if "solder_keys" in request.form:
+ solder_keys = request.form['solder_keys']
+ if "solder_clients" in request.form:
+ solder_clients = request.form['solder_clients']
+ if "solder_env" in request.form:
+ solder_env = request.form['solder_env']
+ if "mods_create" in request.form:
+ mods_create = request.form['mods_create']
+ if "mods_manage" in request.form:
+ mods_manage = request.form['mods_manage']
+ if "mods_delete" in request.form:
+ mods_delete = request.form['mods_delete']
+ if "modpacks_create" in request.form:
+ modpacks_create = request.form['modpacks_create']
+ if "modpacks_manage" in request.form:
+ modpacks_manage = request.form['modpacks_manage']
+ if "modpacks_delete" in request.form:
+ modpacks_delete = request.form['modpacks_delete']
+ User_modpack.update_userpermissions(id, solder_full, solder_users, solder_keys, solder_clients, solder_env, mods_create, mods_manage, mods_delete, modpacks_create, modpacks_manage, modpacks_delete)
+ return redirect(id)
+
+ try:
+ modpacklibrary = Modpack.get_all()
+ except connector.ProgrammingError as e:
+ flash("error when getting modpack list", "error")
+ Database.create_tables()
+ modpacklibrary = []
+
+ return render_template("user.html", userpacks=packs, modpacklibrary=modpacklibrary, user_perms=user_perms)
+
diff --git a/models/user_modpack.py b/models/user_modpack.py
new file mode 100644
index 0000000..fa25bd0
--- /dev/null
+++ b/models/user_modpack.py
@@ -0,0 +1,70 @@
+import datetime
+
+from flask import flash
+
+from .database import Database
+
+
+class User_modpack:
+ def __init__(self, id, user_id, modpack_id, created_at, updated_at):
+ self.id = id
+ self.user_id = user_id
+ self.modpack_id = modpack_id
+ self.created_at = created_at
+ self.updated_at = updated_at
+
+ @classmethod
+ def new(cls, user_id, modpack_id):
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ now = datetime.datetime.now()
+ cur.execute("INSERT INTO user_modpack (user_id, modpack_id, created_at, updated_at) VALUES (%s, %s, %s, %s)", (user_id, modpack_id, now, now))
+ conn.commit()
+ cur.execute("SELECT LAST_INSERT_ID() AS id")
+ id = cur.fetchone()["id"]
+ return cls(id, user_id, modpack_id, now, now)
+
+ @classmethod
+ def delete_user_modpack(cls, id):
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute("DELETE FROM user_modpack WHERE id=%s", (id,))
+ conn.commit()
+ return None
+
+ @staticmethod
+ def get_all_user_modpacks(id) -> list:
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute(
+ """SELECT user_modpack.id, user_modpack.user_id, user_modpack.modpack_id, user_modpack.created_at, user_modpack.updated_at, users.username AS user_name, modpacks.name AS modpack_name
+ FROM user_modpack
+ INNER JOIN users ON user_modpack.user_id = users.id
+ INNER JOIN modpacks ON user_modpack.modpack_id = modpacks.id
+ WHERE user_modpack.user_id = %s
+ """, (id,))
+ rows = cur.fetchall()
+ if rows:
+ return rows
+ return []
+
+ @staticmethod
+ def get_user_permission(id) -> list:
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute("SELECT * FROM user_permissions WHERE user_id = %s", (id,))
+ rows = cur.fetchone()
+ if rows:
+ return rows
+ return []
+
+ @staticmethod
+ def update_userpermissions(id, solder_full, solder_users, solder_keys, solder_clients, solder_env, mods_create, mods_manage, mods_delete, modpacks_create, modpacks_manage, modpacks_delete):
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ now = datetime.datetime.now()
+ cur.execute("""UPDATE user_permissions
+ SET solder_full = %s, solder_users = %s, solder_keys = %s, solder_clients = %s, solder_env = %s, mods_create = %s, mods_manage = %s, mods_delete = %s, modpacks_create = %s, modpacks_manage = %s, modpacks_delete = %s
+ WHERE user_id = %s;""", (solder_full, solder_users, solder_keys, solder_clients, solder_env, mods_create, mods_manage, mods_delete, modpacks_create, modpacks_manage, modpacks_delete, id))
+ conn.commit()
+ return None
\ No newline at end of file
diff --git a/static/css/layout.css b/static/css/layout.css
index 2e916e2..0c8ab8d 100644
--- a/static/css/layout.css
+++ b/static/css/layout.css
@@ -95,4 +95,8 @@ main {
.grid2 {
grid-column: 2;
grid-row: 1;
+}
+
+.spacers {
+ min-height: 5vh;
}
\ No newline at end of file
diff --git a/templates/user.html b/templates/user.html
new file mode 100644
index 0000000..8a62432
--- /dev/null
+++ b/templates/user.html
@@ -0,0 +1,101 @@
+{%extends "layout.html"%} {% set active_page = "userlibrary" %} {%block head%}
+solder.py
+ {%endblock%}{%block main%}
+
+
+
+
+
+ Username |
+ Modpack ID |
+ Modpack Name |
+ Action |
+
+
+
+ {%for mod in userpacks%}
+
+ {{mod.user_name}} |
+ {{mod.modpack_id}} |
+ {{mod.modpack_name}} |
+ |
+
+ {%endfor%}
+
+
+
+
+
+{% endblock %}
+
+{%block aside%}
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/templates/userlibrary.html b/templates/userlibrary.html
index 1d59c8f..2905471 100644
--- a/templates/userlibrary.html
+++ b/templates/userlibrary.html
@@ -22,8 +22,8 @@
{{mod.username}} |
|
From 12c2d82b026f6fc983b54306a256c12a634d80b1 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 15:52:15 +0200
Subject: [PATCH 21/61] remove old unused flash system
---
templates/apikeylibrary.html | 11 -----------
templates/clientlibrary.html | 11 -----------
templates/clients.html | 11 -----------
templates/modlibrary.html | 12 ------------
templates/modpack.html | 11 -----------
templates/modpackbuild.html | 11 -----------
templates/modpacklibrary.html | 10 ----------
templates/modversion.html | 10 ----------
templates/userlibrary.html | 11 -----------
9 files changed, 98 deletions(-)
diff --git a/templates/apikeylibrary.html b/templates/apikeylibrary.html
index bd25615..ef46b53 100644
--- a/templates/apikeylibrary.html
+++ b/templates/apikeylibrary.html
@@ -49,17 +49,6 @@
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
diff --git a/templates/clientlibrary.html b/templates/clientlibrary.html
index 94eaa4c..e51cf69 100644
--- a/templates/clientlibrary.html
+++ b/templates/clientlibrary.html
@@ -54,17 +54,6 @@
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
diff --git a/templates/clients.html b/templates/clients.html
index 268d174..4d86881 100644
--- a/templates/clients.html
+++ b/templates/clients.html
@@ -45,17 +45,6 @@
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
diff --git a/templates/modlibrary.html b/templates/modlibrary.html
index 09e58c7..9386df1 100644
--- a/templates/modlibrary.html
+++ b/templates/modlibrary.html
@@ -106,18 +106,6 @@
-
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
diff --git a/templates/modpack.html b/templates/modpack.html
index 45750f2..1209d2d 100644
--- a/templates/modpack.html
+++ b/templates/modpack.html
@@ -125,17 +125,6 @@
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
diff --git a/templates/modpacklibrary.html b/templates/modpacklibrary.html
index 93d5e2b..272b28d 100644
--- a/templates/modpacklibrary.html
+++ b/templates/modpacklibrary.html
@@ -71,16 +71,6 @@
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %} {% if failed %}
-
- {% endif %}
diff --git a/templates/modversion.html b/templates/modversion.html
index c4ca68b..b416ca5 100644
--- a/templates/modversion.html
+++ b/templates/modversion.html
@@ -160,16 +160,6 @@
- {% if success %}
-
-
The server is currently hashing the file, come back again
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
- {% if success %}
-
-
{{mod.vmd5}}
-
{{mod.vurl}}
-
- {% endif %}
- {% if failed %}
-
- {% endif %}
From a87680bbc83576f90b32811414b11b77d9745712 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 21:10:22 +0200
Subject: [PATCH 22/61] add per modpack access
---
asite.py | 6 ++++++
models/build.py | 13 +++++++++++++
models/user_modpack.py | 29 +++++++++++++++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/asite.py b/asite.py
index 6d77d4b..d91e97b 100644
--- a/asite.py
+++ b/asite.py
@@ -172,6 +172,9 @@ def modpack(id):
if User.get_permission_token(session["token"], "modpacks_manage") == 0:
return redirect(request.referrer)
+
+ if User_modpack.get_user_modpackpermission(session["token"], id) == False:
+ return redirect(request.referrer)
try:
modpack = Modpack.get_by_id(id)
@@ -420,6 +423,9 @@ def modpackbuild(id):
if User.get_permission_token(session["token"], "modpacks_manage") == 0:
return redirect(request.referrer)
+
+ if User_modpack.get_user_modpackpermission(session["token"], Build.get_modpackid_by_id(id)) == False:
+ return redirect(request.referrer)
try:
listmod = Mod.get_all_pretty_names()
diff --git a/models/build.py b/models/build.py
index 3da9150..631a3e9 100644
--- a/models/build.py
+++ b/models/build.py
@@ -89,6 +89,19 @@ def get_modpackname_by_id(cls, id):
flash("unable to get modpackname by id", "error")
return None
return (name)
+
+ @classmethod
+ def get_modpackid_by_id(cls, id):
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute("SELECT modpack_id FROM builds WHERE id = %s", (id,))
+ try:
+ row = cur.fetchone()["modpack_id"]
+ conn.commit()
+ return (row)
+ except:
+ flash("unable to get modpackid by id", "error")
+ return 0
@classmethod
def get_by_id(cls, id):
diff --git a/models/user_modpack.py b/models/user_modpack.py
index fa25bd0..7a73959 100644
--- a/models/user_modpack.py
+++ b/models/user_modpack.py
@@ -48,6 +48,35 @@ def get_all_user_modpacks(id) -> list:
return rows
return []
+ @staticmethod
+ def get_user_modpackpermission(token: str, modpack_id) -> list:
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute("SELECT user_id FROM sessions WHERE token = %s", (token,))
+ try:
+ user_id = cur.fetchone()["user_id"]
+ conn.commit()
+ except:
+ flash("unable to fetch user_id for permission check", "error")
+ return False
+ cur.execute("SELECT solder_full FROM user_permissions WHERE user_id = %s", (user_id,))
+ try:
+ row = cur.fetchone()["solder_full"]
+ conn.commit()
+ if row == 1:
+ return True
+ except:
+ flash("unable to check your admin permission", "error")
+ cur.execute("SELECT modpack_id FROM user_modpack WHERE user_id = %s AND modpack_id = %s", (user_id, modpack_id))
+ try:
+ rows = cur.fetchone()["modpack_id"]
+ conn.commit()
+ if rows == modpack_id:
+ return True
+ except:
+ flash("Permission denied to this modpack", "error")
+ return False
+
@staticmethod
def get_user_permission(id) -> list:
conn = Database.get_connection()
From 34c1a496e9eaf7572bf487ca201a4a20cb52916d Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 22:15:40 +0200
Subject: [PATCH 23/61] change/created by users on user table now works
---
asite.py | 6 +++---
models/session.py | 10 ++++++----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/asite.py b/asite.py
index d91e97b..40bd532 100644
--- a/asite.py
+++ b/asite.py
@@ -392,7 +392,7 @@ def userlibrary_post():
return redirect(url_for('asite.userlibrary'))
if "newuser" not in request.form:
return redirect(url_for('asite.userlibrary'))
- User.new(request.form["newuser"], request.form["newemail"], request.form["newpassword"], request.remote_addr, '1')
+ User.new(request.form["newuser"], request.form["newemail"], request.form["newpassword"], request.remote_addr, Session.get_user_id(session["token"]))
return redirect(url_for('asite.userlibrary'))
if "form2-submit" in request.form:
if User.get_permission_token(session["token"], "solder_users") == 0:
@@ -402,14 +402,14 @@ def userlibrary_post():
User.delete(request.form["delete_id"])
return redirect(url_for('asite.userlibrary'))
if "changeuser_submit" in request.form:
- if session.get_user_id(session["token"]) != request.form["changeuser_id"]:
+ if Session.get_user_id(session["token"]) != request.form["changeuser_id"]:
if User.get_permission_token(session["token"], "solder_users") == 0:
return redirect(request.referrer)
if "changeuser_id" not in request.form:
return redirect(url_for('asite.userlibrary'))
if "changeuser_password" not in request.form:
return redirect(url_for('asite.userlibrary'))
- User.change(request.form["changeuser_id"], request.form["changeuser_password"], request.remote_addr, '1')
+ User.change(request.form["changeuser_id"], request.form["changeuser_password"], request.remote_addr, Session.get_user_id(session["token"]))
return redirect(url_for('asite.userlibrary'))
return redirect(url_for('asite.userlibrary'))
diff --git a/models/session.py b/models/session.py
index 749bae6..4e5975d 100644
--- a/models/session.py
+++ b/models/session.py
@@ -5,6 +5,8 @@
import time
from datetime import datetime
+from flask import flash
+
from .database import Database
@@ -47,13 +49,13 @@ def get_and_update_from_token(cls, token: str) -> Session:
@staticmethod
def get_user_id(token: str):
conn = Database.get_connection()
- cur = conn.cursor()
+ cur = conn.cursor(dictionary=True)
cur.execute("SELECT user_id FROM sessions WHERE token = %s", (token,))
try:
- user_id = cur.fetchone()["user_id"]
- return (user_id)
+ return cur.fetchone()["user_id"]
except:
- return None
+ flash("could not fetch user id", "error")
+ return 0
@staticmethod
def new_session(ip: str, user) -> str:
From 1159da67eaa7a7599d969d6788ae96716e1f95e0 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 22:52:59 +0200
Subject: [PATCH 24/61] don't allow users without user perm to see other users
---
asite.py | 9 +++++----
models/user.py | 22 ++++++++++++++++++++++
templates/userlibrary.html | 2 ++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/asite.py b/asite.py
index 40bd532..78cba57 100644
--- a/asite.py
+++ b/asite.py
@@ -361,8 +361,7 @@ def userlibrary():
# New or invalid session, send to login
return redirect(url_for('alogin.login'))
- if User.get_permission_token(session["token"], "solder_users") == 0:
- return redirect(request.referrer)
+ fulluserid = User.get_fulluser(session["token"])
try:
users = User.get_all_users()
@@ -371,7 +370,7 @@ def userlibrary():
users = []
flash("error when accessing user table", "error")
- return render_template("userlibrary.html", users=users)
+ return render_template("userlibrary.html", users=users, fulluserid=fulluserid)
@asite.route("/userlibrary", methods=["POST"])
@@ -402,7 +401,9 @@ def userlibrary_post():
User.delete(request.form["delete_id"])
return redirect(url_for('asite.userlibrary'))
if "changeuser_submit" in request.form:
- if Session.get_user_id(session["token"]) != request.form["changeuser_id"]:
+ userid = str(Session.get_user_id(session["token"]))
+ changeid = request.form["changeuser_id"]
+ if userid not in changeid:
if User.get_permission_token(session["token"], "solder_users") == 0:
return redirect(request.referrer)
if "changeuser_id" not in request.form:
diff --git a/models/user.py b/models/user.py
index 188ccfd..78b2916 100644
--- a/models/user.py
+++ b/models/user.py
@@ -118,6 +118,28 @@ def get_permission_token(token: str, db_column):
except:
flash("unable to check your permission", "error")
return 0
+
+ @staticmethod
+ def get_fulluser(token: str):
+ conn = Database.get_connection()
+ cur = conn.cursor(dictionary=True)
+ cur.execute("SELECT user_id FROM sessions WHERE token = %s", (token,))
+ try:
+ user_id = cur.fetchone()["user_id"]
+ conn.commit()
+ except:
+ flash("unable to fetch user_id for permission check", "error")
+ return 0
+ cur.execute("SELECT * FROM user_permissions WHERE user_id = %s", (user_id,))
+ try:
+ row = cur.fetchone()
+ if row["solder_full"] == 1:
+ return 0
+ if row["solder_user"] == 1:
+ return 0
+ return user_id
+ except:
+ return user_id
@staticmethod
def get_all_users() -> list:
diff --git a/templates/userlibrary.html b/templates/userlibrary.html
index 6be7c94..a0d1550 100644
--- a/templates/userlibrary.html
+++ b/templates/userlibrary.html
@@ -16,6 +16,7 @@
{%for mod in users%}
+ {% if fulluserid==0 or fulluserid==mod.id %}
{{mod.id}} |
{{mod.email}} |
@@ -28,6 +29,7 @@
+ {% endif %}
{%endfor%}
From fded3fd62fe548e2ff1edafb53f43c855fdda0f9 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 23:16:28 +0200
Subject: [PATCH 25/61] add ability to enable optinal/server builds
---
asite.py | 10 +++++++---
models/modpack.py | 6 +++---
templates/modpacklibrary.html | 24 +++++++++++-------------
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/asite.py b/asite.py
index 78cba57..c9d1f4e 100644
--- a/asite.py
+++ b/asite.py
@@ -592,11 +592,15 @@ def modpacklibrary_post():
Modpack.new(request.form["pretty_name"], request.form["name"], hidden, private, "0")
return redirect(url_for('asite.modpacklibrary'))
if "hidden_submit" in request.form:
- Modpack.update_checkbox(request.form["hidden_modid"], request.form["hidden_check"], "hidden", "modpacks")
+ Modpack.update_checkbox(request.form["modid"], request.form["check"], "hidden", "modpacks")
if "private_submit" in request.form:
- Modpack.update_checkbox(request.form["private_modid"], request.form["private_check"], "private", "modpacks")
+ Modpack.update_checkbox(request.form["modid"], request.form["check"], "private", "modpacks")
if "pinned_submit" in request.form:
- Modpack.update_checkbox(request.form["pinned_modid"], request.form["pinned_check"], "pinned", "modpacks")
+ Modpack.update_checkbox(request.form["modid"], request.form["check"], "pinned", "modpacks")
+ if "optional_submit" in request.form:
+ Modpack.update_checkbox(request.form["modid"], request.form["check"], "enable_optionals", "modpacks")
+ if "server_submit" in request.form:
+ Modpack.update_checkbox(request.form["modid"], request.form["check"], "enable_server", "modpacks")
return redirect(url_for('asite.modpacklibrary'))
diff --git a/models/modpack.py b/models/modpack.py
index ef10c73..bf74d94 100644
--- a/models/modpack.py
+++ b/models/modpack.py
@@ -45,10 +45,10 @@ def delete_modpack(cls, id):
return None
@classmethod
- def update_checkbox(cls, id, value, column, table):
+ def update_checkbox(cls, where_id, value, column, table):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
- cur.execute("UPDATE {} SET {} = %s WHERE id = %s".format(table, column), (value, id))
+ cur.execute("UPDATE {} SET {} = %s WHERE id = %s".format(table, column), (value, where_id))
conn.commit()
return None
@@ -99,7 +99,7 @@ def get_all() -> list:
cur.execute("SELECT * FROM modpacks")
rows = cur.fetchall()
if rows:
- return [Modpack(row["id"], row["name"], row["slug"], row["recommended"], row["latest"], row["created_at"], row["updated_at"], row["order"], row["hidden"], row["private"], row["pinned"]) for row in rows]
+ return rows
return []
def get_builds(self):
diff --git a/templates/modpacklibrary.html b/templates/modpacklibrary.html
index 272b28d..1d208ef 100644
--- a/templates/modpacklibrary.html
+++ b/templates/modpacklibrary.html
@@ -13,6 +13,8 @@
Hidden |
Private |
Pin to menu |
+ Optionalbuilds |
+ Serverbuilds |
Action |
@@ -23,9 +25,11 @@
{{mod.name}} ({{mod.slug}}) |
{{mod.recommended}} |
{{mod.latest}} |
- |
- |
- |
+ |
+ |
+ |
+ |
+ |
|
@@ -34,19 +38,13 @@
-
-
{% endblock %}
From a70368134ac8b6a46d3c22332a295bf14be2e1d2 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 23:16:56 +0200
Subject: [PATCH 26/61] reuse code instead of copy paste
---
asite.py | 10 +++++-----
templates/modpack.html | 30 +++++++-----------------------
2 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/asite.py b/asite.py
index c9d1f4e..687be30 100644
--- a/asite.py
+++ b/asite.py
@@ -208,19 +208,19 @@ def modpack(id):
Build.new(id, request.form["version"], request.form["mcversion"], publish, private, min_java, request.form["memory"], clonebuild)
return redirect(id)
if "recommended_submit" in request.form:
- Build.update_checkbox(id, request.form["recommended_modid"], "recommended", "modpacks")
+ Build.update_checkbox(id, request.form["modid"], "recommended", "modpacks")
return redirect(id)
if "latest_submit" in request.form:
- Build.update_checkbox(id, request.form["latest_modid"], "latest", "modpacks")
+ Build.update_checkbox(id, request.form["modid"], "latest", "modpacks")
return redirect(id)
if "is_published_submit" in request.form:
- Build.update_checkbox(request.form["is_published_modid"], request.form["is_published_check"], "is_published", "builds")
+ Build.update_checkbox(request.form["modid"], request.form["check"], "is_published", "builds")
return redirect(id)
if "private_submit" in request.form:
- Build.update_checkbox(request.form["private_modid"], request.form["private_check"], 'private', 'builds')
+ Build.update_checkbox(request.form["modid"], request.form["check"], 'private', 'builds')
return redirect(id)
if "marked_submit" in request.form:
- Build.update_checkbox_marked(request.form["marked_modid"], request.form["marked_check"])
+ Build.update_checkbox_marked(request.form["modid"], request.form["check"])
return redirect(id)
if "changelog_submit" in request.form:
oldversion = request.form["changelog_oldver"]
diff --git a/templates/modpack.html b/templates/modpack.html
index 1209d2d..b3c6c58 100644
--- a/templates/modpack.html
+++ b/templates/modpack.html
@@ -25,11 +25,11 @@
{{mod.version}} |
{{mod.minecraft}} |
{{mod.count}} |
- |
- |
- |
- |
- |
+ |
+ |
+ |
+ |
+ |
@@ -42,28 +42,12 @@
-
-
-
-
From e90b15f20ef6a3805fec00ef777a6fc9f808713e Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Sun, 1 Sep 2024 23:22:20 +0200
Subject: [PATCH 27/61] Update README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 4927c65..325bfa3 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,6 @@ solder.py is even compatible with original solder's database, visit the install
+ Maven integration
+ Modrinth integration
+ MCIL export support
-+ Advanced user management
## Unfinished Features in dev
From fa0c5637013d2b15db2c4eff60579a4ccd17bd7d Mon Sep 17 00:00:00 2001
From: Sebastian Kuipers
Date: Mon, 2 Sep 2024 15:26:06 +0200
Subject: [PATCH 28/61] API now properly serves server and optional builds
---
api.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/api.py b/api.py
index 22e014c..5d16e23 100644
--- a/api.py
+++ b/api.py
@@ -48,14 +48,15 @@ def modpack_slug(slug: str):
return jsonify({"error": "Modpack does not exist/Build does not exist"}), 404
-@api.route("/api/modpack//")
+@api.route("/api/modpack//")
def modpack_slug_build(slugstring: str, buildstring: str):
modpack = Modpack.get_by_cid_slug(request.args.get("cid"), slugstring)
if not modpack:
return jsonify({"error": "Modpack does not exist/Build does not exist"}), 404
buildsplit = buildstring.split("-")
- buildsplit += ""
+ buildsplit.append("")
+ print(buildsplit)
buildnumber = buildsplit[0]
buildtag = buildsplit[1]
build = modpack.get_build(buildnumber)
From eb33009aa28e061bf8804ebd2bc332f3f6210473 Mon Sep 17 00:00:00 2001
From: maggi373 <40539743+maggi373@users.noreply.github.com>
Date: Tue, 3 Sep 2024 23:01:16 +0200
Subject: [PATCH 29/61] fix classmethods when it should be staticmethod
---
models/build.py | 20 ++++++++++----------
models/build_modversion.py | 8 ++++----
models/client.py | 4 ++--
models/client_modpack.py | 4 ++--
models/mod.py | 8 ++++----
models/modversion.py | 16 ++++++++--------
models/user.py | 12 ++++++------
models/user_modpack.py | 4 ++--
templates/user.html | 2 +-
9 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/models/build.py b/models/build.py
index 631a3e9..425a0cd 100644
--- a/models/build.py
+++ b/models/build.py
@@ -40,8 +40,8 @@ def new(cls, modpack_id, version, minecraft, is_published, private, min_java, mi
conn.commit()
cls(id, modpack_id, version, now, now, minecraft, "0", is_published, private, min_java, min_memory, "0")
- @classmethod
- def delete_build(cls, id):
+ @staticmethod
+ def delete_build(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM build_modversion WHERE build_id = %s", (id,))
@@ -49,8 +49,8 @@ def delete_build(cls, id):
conn.commit()
return None
- @classmethod
- def update(cls, id, version, minecraft, is_published, private, min_java, min_memory):
+ @staticmethod
+ def update(id, version, minecraft, is_published, private, min_java, min_memory):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
now = datetime.datetime.now()
@@ -60,16 +60,16 @@ def update(cls, id, version, minecraft, is_published, private, min_java, min_mem
conn.commit()
return None
- @classmethod
- def update_checkbox(cls, id, value, column, table):
+ @staticmethod
+ def update_checkbox(id, value, column, table):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("UPDATE {} SET {} = %s WHERE id = %s".format(table, column), (value, id))
conn.commit()
return None
- @classmethod
- def update_checkbox_marked(cls, id, value):
+ @staticmethod
+ def update_checkbox_marked(id, value):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("UPDATE builds SET marked = '0'")
@@ -77,8 +77,8 @@ def update_checkbox_marked(cls, id, value):
conn.commit()
return None
- @classmethod
- def get_modpackname_by_id(cls, id):
+ @staticmethod
+ def get_modpackname_by_id(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("SELECT modpack_id FROM builds WHERE id = %s", (id,))
diff --git a/models/build_modversion.py b/models/build_modversion.py
index 022e6dc..dbdf009 100644
--- a/models/build_modversion.py
+++ b/models/build_modversion.py
@@ -11,16 +11,16 @@ def __init__(self, id, modversion_id, build_id, created_at, updated_at, optional
self.updated_at = updated_at
self.optional = optional
- @classmethod
- def delete_build_modversion(cls, id):
+ @staticmethod
+ def delete_build_modversion(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM build_modversion WHERE id = %s", (id,))
conn.commit()
return None
- @classmethod
- def update_optional(cls, modversion_id, optional, build_id):
+ @staticmethod
+ def update_optional(modversion_id, optional, build_id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("""UPDATE build_modversion
diff --git a/models/client.py b/models/client.py
index cfce086..0978d85 100644
--- a/models/client.py
+++ b/models/client.py
@@ -23,8 +23,8 @@ def new(cls, name, uuid):
id = cur.fetchone()["id"]
return cls(id, name, uuid, now, now)
- @classmethod
- def delete_client(cls, id):
+ @staticmethod
+ def delete_client(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM clients WHERE id=%s", (id,))
diff --git a/models/client_modpack.py b/models/client_modpack.py
index 7ac7cb6..ba68177 100644
--- a/models/client_modpack.py
+++ b/models/client_modpack.py
@@ -24,8 +24,8 @@ def new(cls, client_id, modpack_id):
id = cur.fetchone()["id"]
return cls(id, client_id, modpack_id, now, now, "", "")
- @classmethod
- def delete_client_modpack(cls, id):
+ @staticmethod
+ def delete_client_modpack(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM client_modpack WHERE id=%s", (id,))
diff --git a/models/mod.py b/models/mod.py
index 929b688..f384642 100644
--- a/models/mod.py
+++ b/models/mod.py
@@ -29,8 +29,8 @@ def new(cls, name, description, author, link, pretty_name, side, modtype, note):
id = cur.fetchone()["id"]
return cls(id, name, description, author, link, now, now, pretty_name, side, modtype, note)
- @classmethod
- def update(cls, id, name, description, author, link, pretty_name, side, modtype, note):
+ @staticmethod
+ def update(id, name, description, author, link, pretty_name, side, modtype, note):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
now = datetime.datetime.now()
@@ -42,8 +42,8 @@ def update(cls, id, name, description, author, link, pretty_name, side, modtype,
id = cur.fetchone()["id"]
return None
- @classmethod
- def delete_mod(cls, id):
+ @staticmethod
+ def delete_mod(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("SELECT * FROM modversions WHERE mod_id = %s", (id,))
diff --git a/models/modversion.py b/models/modversion.py
index f3621e0..98f0577 100644
--- a/models/modversion.py
+++ b/models/modversion.py
@@ -39,8 +39,8 @@ def new(cls, mod_id, version, mcversion, md5, filesize, markedbuild, url="0", ja
Modversion.update_modversion_jarmd5(id, jarmd5)
return cls(id, mod_id, version, mcversion, md5, now, now, filesize)
- @classmethod
- def add_modversion_to_selected_build(cls, modver_id, mod_id, build_id, marked, optional):
+ @staticmethod
+ def add_modversion_to_selected_build(modver_id, mod_id, build_id, marked, optional):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
if marked == "1":
@@ -71,24 +71,24 @@ def add_modversion_to_selected_build(cls, modver_id, mod_id, build_id, marked, o
conn.commit()
return None
- @classmethod
- def update_modversion_in_build(cls, oldmodver_id, modver_id, build_id):
+ @staticmethod
+ def update_modversion_in_build(oldmodver_id, modver_id, build_id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("UPDATE build_modversion SET modversion_id = %s WHERE modversion_id = %s AND build_id = %s", (modver_id, oldmodver_id, build_id))
conn.commit()
return None
- @classmethod
- def update_modversion_jarmd5(cls, id, jarmd5):
+ @staticmethod
+ def update_modversion_jarmd5(id, jarmd5):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("UPDATE modversions SET jarmd5 = %s WHERE id = %s", (jarmd5, id))
conn.commit()
return None
- @classmethod
- def delete_modversion(cls, id):
+ @staticmethod
+ def delete_modversion(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM modversions WHERE id=%s", (id,))
diff --git a/models/user.py b/models/user.py
index 78b2916..efa61b9 100644
--- a/models/user.py
+++ b/models/user.py
@@ -41,8 +41,8 @@ def new(cls, username, email, hash1, ip, creator_id):
conn.commit()
return cls(id, username, email, password, ip, ip, now, now, ip, creator_id, creator_id)
- @classmethod
- def change(cls, userid, hash1, ip, creator_id):
+ @staticmethod
+ def change(userid, hash1, ip, creator_id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
now = datetime.datetime.now()
@@ -53,8 +53,8 @@ def change(cls, userid, hash1, ip, creator_id):
conn.commit()
return None
- @classmethod
- def delete(cls, id):
+ @staticmethod
+ def delete(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM users WHERE id=%s", (id,))
@@ -82,8 +82,8 @@ def get_by_username(cls, username):
return cls(row["id"], row["username"], row["email"], row["password"], row["created_ip"], row["last_ip"], row["created_at"], row["updated_at"], row["updated_by_ip"], row["created_by_user_id"], row["updated_by_user_id"])
return None
- @classmethod
- def get_userid(cls, username):
+ @staticmethod
+ def get_userid(username):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("SELECT id FROM users WHERE username = %s", (username,))
diff --git a/models/user_modpack.py b/models/user_modpack.py
index 7a73959..7cbeae6 100644
--- a/models/user_modpack.py
+++ b/models/user_modpack.py
@@ -24,8 +24,8 @@ def new(cls, user_id, modpack_id):
id = cur.fetchone()["id"]
return cls(id, user_id, modpack_id, now, now)
- @classmethod
- def delete_user_modpack(cls, id):
+ @staticmethod
+ def delete_user_modpack(id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute("DELETE FROM user_modpack WHERE id=%s", (id,))
diff --git a/templates/user.html b/templates/user.html
index 8a62432..deef8c4 100644
--- a/templates/user.html
+++ b/templates/user.html
@@ -51,7 +51,7 @@
|