Pre-allocate random colors

Pre-allocate badge colors from a palette so that everyone is
not blue.

Change-Id: Id72711803e708dd51a4a1121bdd54dba30801ac0
This commit is contained in:
Thierry Carrez 2018-02-05 16:26:12 +01:00
parent 5575015e33
commit 05ae383f69
1 changed files with 16 additions and 1 deletions

View File

@ -15,10 +15,11 @@
# limitations under the License.
import calendar
import datetime
from itertools import chain
import json
import os
import datetime
import random
class PTGDataBase():
@ -41,6 +42,20 @@ class PTGDataBase():
for time, track in bookings.items():
if track not in self.data['tracks']:
self.data['tracks'].append(track)
self.data['colors'][track] = random.choice([
'#596468',
'#9ea8ad',
'#b57506',
'#f8ac29',
'#5b731a',
'#9dc62d',
'#156489',
'#27a3dd',
'#2a6d3c',
'#3fa45b',
'#930a0a',
'#dc0d0e',
])
# Rebuild 'additional' with rooms and slots from configuration, but
# use saved data where the room/slot is preserved