Add mapcodes

This commit is contained in:
magmaus3 2022-11-20 15:51:20 +01:00
parent e66ed05ef7
commit 03969a18d7
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
2 changed files with 8 additions and 2 deletions

View file

@ -47,3 +47,8 @@ def auth_check(Authorization):
return False, "wrongpass" return False, "wrongpass"
return True, query return True, query
def id_to_mapcode(id_):
return hex(id_).replace("0x", "").rjust(8, "0")[0:8].upper()

View file

@ -277,13 +277,14 @@ async def upload_map(
elif authcheck[0]: elif authcheck[0]:
print(authcheck) print(authcheck)
userData = types.User(**authcheck[1]) userData = types.User(**authcheck[1])
MapCode = "SUSYBAKA" # FIXME Add mapcodes correctly ID = len(list(db.maps_collection.find({}))) + 1
MapCode = db.id_to_mapcode(ID) # FIXME Add mapcodes correctly
db.maps_collection.insert_one( db.maps_collection.insert_one(
{ {
**types.Map( **types.Map(
CreatorName=userData.Username, CreatorName=userData.Username,
CreatorId=userData.ID, CreatorId=userData.ID,
ID=len(list(db.maps_collection.find({}))) + 1, ID=ID,
Name=mapName, Name=mapName,
Description=mapDescription, Description=mapDescription,
Version=mapVersion, Version=mapVersion,