Update model

This commit is contained in:
Dominic Zimmer 2020-07-18 00:54:32 +02:00
parent 3174465be2
commit f140df2146
3 changed files with 16 additions and 13 deletions

View File

@ -108,12 +108,15 @@ class Model(object):
raise Exception("No such user") raise Exception("No such user")
@ApiMethod @ApiMethod
async def set_max_score(self, authtoken, newmaxscore): async def set_max_score(self, authtoken, uuid, newmaxscore):
self.verify_admin(authtoken) self.verify_admin(authtoken)
if newscore <= user.maxscore: if uuid not in self.users:
user.score = newscore raise Exception("No such user")
user = self.users[uuid]
if newmaxscore < user.maxscore:
raise Exception("Tried to lower maxscore. That's bad...")
else: else:
raise Exception("Tried to raise user score above maxscore") user.maxscore = newmaxscore
class User: class User:

View File

@ -4,36 +4,36 @@
"uuid": "u4zhlm4y2w4alg4adpj3amw67ivhtfbx", "uuid": "u4zhlm4y2w4alg4adpj3amw67ivhtfbx",
"name": "Andi", "name": "Andi",
"score": 78, "score": 78,
"maxscore": 100, "maxscore": 125,
"timeout": 0 "timeout": 0
}, },
"bd63gy2wfdk72q3mk6ooesanx4mo33ao": { "bd63gy2wfdk72q3mk6ooesanx4mo33ao": {
"uuid": "bd63gy2wfdk72q3mk6ooesanx4mo33ao", "uuid": "bd63gy2wfdk72q3mk6ooesanx4mo33ao",
"name": "Felix", "name": "Felix",
"score": 52, "score": 276,
"maxscore": 75, "maxscore": 300,
"timeout": 0 "timeout": 0
}, },
"5wn24yko36muqoxohczbf53i6p3hx2pa": { "5wn24yko36muqoxohczbf53i6p3hx2pa": {
"uuid": "5wn24yko36muqoxohczbf53i6p3hx2pa", "uuid": "5wn24yko36muqoxohczbf53i6p3hx2pa",
"name": "Daki", "name": "Daki",
"score": 62, "score": 62,
"maxscore": 100, "maxscore": 125,
"timeout": 0 "timeout": 0
}, },
"iz2z4c5wkxldc2vdjh66zubxcsvb5qjs": { "iz2z4c5wkxldc2vdjh66zubxcsvb5qjs": {
"uuid": "iz2z4c5wkxldc2vdjh66zubxcsvb5qjs", "uuid": "iz2z4c5wkxldc2vdjh66zubxcsvb5qjs",
"name": "Cindy", "name": "Cindy",
"score": 91, "score": 100,
"maxscore": 100, "maxscore": 200,
"timeout": 0 "timeout": 0
}, },
"pfkkuzo4y2tmopgc5o6n6zvhy7dyvqdy": { "pfkkuzo4y2tmopgc5o6n6zvhy7dyvqdy": {
"uuid": "pfkkuzo4y2tmopgc5o6n6zvhy7dyvqdy", "uuid": "pfkkuzo4y2tmopgc5o6n6zvhy7dyvqdy",
"name": "Dominik", "name": "Dominik",
"score": 46, "score": 46,
"maxscore": 50, "maxscore": 150,
"timeout": 0 "timeout": 0
} }
} }
} }

View File

@ -52,7 +52,7 @@
<div class="biceps"> <div class="biceps">
<div> <div>
<input type="number" id="sellvalue" value = "1" > <input type="number" id="sellvalue" value = "1" >
<button id="sell">Sell</button> <input type="button" id="sell" value="Sell">
</div> </div>
</div> </div>