Split up function colorizing non-colored tracks
Make colorize() its own independent function and call it whenever tracks are added. Change-Id: Ieb0b9ce162faac42ec4aaeac24976c62d0b6077e
This commit is contained in:
parent
21d77e09f8
commit
c12a4956be
35
ptgbot/db.py
35
ptgbot/db.py
|
@ -49,20 +49,8 @@ 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',
|
||||
])
|
||||
|
||||
self.colorize()
|
||||
|
||||
def add_now(self, track, session):
|
||||
self.data['now'][track] = session
|
||||
|
@ -78,6 +66,24 @@ class PTGDataBase():
|
|||
self.data['colors'][track] = color
|
||||
self.save()
|
||||
|
||||
def colorize(self):
|
||||
for track in self.data['tracks']:
|
||||
if track not in self.data['colors']:
|
||||
self.add_color(track, random.choice([
|
||||
'#596468',
|
||||
'#9ea8ad',
|
||||
'#b57506',
|
||||
'#f8ac29',
|
||||
'#5b731a',
|
||||
'#9dc62d',
|
||||
'#156489',
|
||||
'#27a3dd',
|
||||
'#2a6d3c',
|
||||
'#3fa45b',
|
||||
'#930a0a',
|
||||
'#dc0d0e',
|
||||
]))
|
||||
|
||||
def get_track_room(self, track):
|
||||
# This simplified version returns the first room the track is
|
||||
# scheduled in for the day. If the event does not run on this
|
||||
|
@ -112,6 +118,7 @@ class PTGDataBase():
|
|||
for track in tracks:
|
||||
if track not in self.data['tracks']:
|
||||
self.data['tracks'].append(track)
|
||||
self.colorize()
|
||||
self.save()
|
||||
|
||||
def del_tracks(self, tracks):
|
||||
|
|
Loading…
Reference in New Issue