implement player blacklisting for gdpr

This commit is contained in:
2021-03-25 13:13:20 +01:00
parent 04f251a702
commit 432d0d4ce1
4 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@@ -16,3 +16,4 @@ static/moment.js
*.exe
*.sqlite
*.png
blacklist.json

View File

@@ -25,6 +25,13 @@ or with a runner like *waitress*:
the *DB_PATH* is set in *config.py* in this case.
# GDPR: Blacklisting players
Players can be blacklisted by name via a *blacklist.json* file in the project root.
{
"blacklist" : ["name", "name_2"]
}
# Preview
![open-web-leaderboard](https://media.atlantishq.de/leaderboard-github-picture.png)

View File

@@ -1,6 +1,8 @@
import json
import datetime
import player
import json
import os
class Round:
def __init__(self, dbRow):
@@ -18,6 +20,21 @@ class Round:
self.winnerSide = winnerSide
self.duration = datetime.timedelta(seconds=int(duration))
self.blacklist = False
blacklistNames = []
blacklistFile = "blacklist.json"
if os.path.isfile(blacklistFile):
blacklistNames = json.load(blacklistFile)["blacklist"]
for name in blacklistNames:
for p in self.winners:
if p.name == name:
self.blacklist = True
for p in self.losers:
if p.name == name:
self.blacklist = True
if winnerSide == 2:
self.winnerSideString = "Security"
self.loserSideString = "Insurgent"

View File

@@ -42,6 +42,8 @@ def singleRound():
r = db.getRoundByTimestamp(timestamp)
if not r:
return ("Round not found", 404)
elif r.blacklist:
return ("Unavailable due to pending GDPR deletion request", 451)
r = db.calcRatingChanges(r)
if not r: