mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
implement player blacklisting for gdpr
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@ static/moment.js
|
|||||||
*.exe
|
*.exe
|
||||||
*.sqlite
|
*.sqlite
|
||||||
*.png
|
*.png
|
||||||
|
blacklist.json
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ or with a runner like *waitress*:
|
|||||||
|
|
||||||
the *DB_PATH* is set in *config.py* in this case.
|
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
|
# Preview
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
17
Round.py
17
Round.py
@@ -1,6 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
import player
|
import player
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
class Round:
|
class Round:
|
||||||
def __init__(self, dbRow):
|
def __init__(self, dbRow):
|
||||||
@@ -18,6 +20,21 @@ class Round:
|
|||||||
self.winnerSide = winnerSide
|
self.winnerSide = winnerSide
|
||||||
self.duration = datetime.timedelta(seconds=int(duration))
|
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:
|
if winnerSide == 2:
|
||||||
self.winnerSideString = "Security"
|
self.winnerSideString = "Security"
|
||||||
self.loserSideString = "Insurgent"
|
self.loserSideString = "Insurgent"
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ def singleRound():
|
|||||||
r = db.getRoundByTimestamp(timestamp)
|
r = db.getRoundByTimestamp(timestamp)
|
||||||
if not r:
|
if not r:
|
||||||
return ("Round not found", 404)
|
return ("Round not found", 404)
|
||||||
|
elif r.blacklist:
|
||||||
|
return ("Unavailable due to pending GDPR deletion request", 451)
|
||||||
r = db.calcRatingChanges(r)
|
r = db.calcRatingChanges(r)
|
||||||
|
|
||||||
if not r:
|
if not r:
|
||||||
|
|||||||
Reference in New Issue
Block a user