From 432d0d4ce1afb0959411bff7024e9491141e62fb Mon Sep 17 00:00:00 2001 From: Sheppy Date: Thu, 25 Mar 2021 13:13:20 +0100 Subject: [PATCH] implement player blacklisting for gdpr --- .gitignore | 1 + README.md | 7 +++++++ Round.py | 17 +++++++++++++++++ server.py | 2 ++ 4 files changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index 946df98..752d977 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ static/moment.js *.exe *.sqlite *.png +blacklist.json diff --git a/README.md b/README.md index 06308da..93e3aab 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Round.py b/Round.py index 6791bf0..50fc1a0 100644 --- a/Round.py +++ b/Round.py @@ -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" diff --git a/server.py b/server.py index 1693a0f..31954cc 100755 --- a/server.py +++ b/server.py @@ -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: