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")
@ApiMethod
async def set_max_score(self, authtoken, newmaxscore):
async def set_max_score(self, authtoken, uuid, newmaxscore):
self.verify_admin(authtoken)
if newscore <= user.maxscore:
user.score = newscore
if uuid not in self.users:
raise Exception("No such user")
user = self.users[uuid]
if newmaxscore < user.maxscore:
raise Exception("Tried to lower maxscore. That's bad...")
else:
raise Exception("Tried to raise user score above maxscore")
user.maxscore = newmaxscore
class User:

View File

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

View File

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