fix downloading and displaying patches for seeds/rooms with teams

This commit is contained in:
Fabian Dill
2021-01-03 18:28:07 +01:00
parent 07954fc230
commit eb58ee2422
6 changed files with 44 additions and 34 deletions

View File

@@ -39,8 +39,14 @@ def uploads():
if file.filename.endswith(banned_zip_contents):
return "Uploaded data contained a rom file, which is likely to contain copyrighted material. Your file was deleted."
elif file.filename.endswith(".bmbp"):
player = int(file.filename.split("P")[1].split(".")[0].split("_")[0])
patches.add(Patch(data=zfile.open(file, "r").read(), player=player))
# get probable team and player ID from filename. Could use a better method.
splitted = file.filename.split("/")[-1][3:].split("P", 1)
player = int(splitted[1].split(".")[0].split("_")[0])
if "T" in splitted[0]:
team = int(splitted[0].split("T")[1].split(".")[0].split("_")[0]) - 1
else:
team = 0
patches.add(Patch(data=zfile.open(file, "r").read(), player=player, team=team))
elif file.filename.endswith(".txt"):
spoiler = zfile.open(file, "r").read().decode("utf-8-sig")
elif file.filename.endswith("multidata"):