Fix bugs in model, Add pretty model

This commit is contained in:
Dominic Zimmer 2020-07-17 22:31:09 +02:00
parent b03f91a8d4
commit 66150f524a
2 changed files with 32 additions and 92 deletions

View File

@ -30,9 +30,9 @@ class Model(object):
def __init__(self, model = dict()):
self.filename = "scoreboard.json"
if "users" not in model:
model["users"] = list()
model["users"] = {}
print(f"loaded model: {model}")
self.users = { User(modelstring).uuid : User(modelstring) for modelstring in model["users"]}
self.users = { uuid : User(model=model["users"][uuid]) for uuid in model["users"]}
#for _ in range(5):
# newuser = User()
@ -40,12 +40,12 @@ class Model(object):
self.secretlookup = { self.users[uuid].get_secret() : uuid for uuid in self.users }
print(self.secretlookup)
#print(self.users)
def to_json(self):
model = {
"users": [self.users[user].to_json() for user in self.users ],
"users": { uuid: self.users[uuid].to_json() for uuid in self.users },
}
print(model)
return model
def verify_user(self, authtoken):

View File

@ -1,99 +1,39 @@
{
"users": [
{
"uuid": "bnqkcmu3vd3fq5fu",
"name": {
"uuid": "t55sfdftsozzy3mi",
"name": {
"uuid": "sprnnogu3cvzzsqf",
"name": "Default User Name",
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"users": {
"zgzbbdf5ulagy5md": {
"uuid": "zgzbbdf5ulagy5md",
"name": "Andi",
"score": 78,
"maxscore": 100,
"timeout": 0
},
{
"uuid": "sywskga5s3m6wxuq",
"name": {
"uuid": "zq2tratnuyfbfrx2",
"name": {
"uuid": "c5lrovzryckbxgwg",
"name": "Default User Name",
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"zjik7wdl7yrm6bb3": {
"uuid": "zjik7wdl7yrm6bb3",
"name": "Felix",
"score": 52,
"maxscore": 75,
"timeout": 0
},
{
"uuid": "ytpvp4dopx54gfld",
"name": {
"uuid": "snmtkzofojtqma3a",
"name": {
"uuid": "wxl42rw4zdghjgve",
"name": "Default User Name",
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"zp7v3lnpapnndclk": {
"uuid": "zp7v3lnpapnndclk",
"name": "Daki",
"score": 62,
"maxscore": 100,
"timeout": 0
},
{
"uuid": "dxkahhq65uo63xqp",
"name": {
"uuid": "6u5z6po6gtmh52fr",
"name": {
"uuid": "shnisaos4vxnfcvq",
"name": "Default User Name",
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"2vsxkkw3d547jhqk": {
"uuid": "2vsxkkw3d547jhqk",
"name": "Cindy",
"score": 91,
"maxscore": 100,
"timeout": 0
},
{
"uuid": "3uw4wif2heales72",
"name": {
"uuid": "fg7kxyv36ls6a6w5",
"name": {
"uuid": "72onbiw4phvtd54y",
"name": "Default User Name",
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"timeout": 0
},
"score": 0,
"maxscore": 0,
"66w5o44yc7wf7y27": {
"uuid": "66w5o44yc7wf7y27",
"name": "Dominik",
"score": 46,
"maxscore": 50,
"timeout": 0
}
]
}
}