Add "location" tracking for rooms

One of the things that's hard about using the ptg page is that you
don't know where things are located. This allows you to set the
location on a room, which is displayed in a 3rd column, and will be
persistent after a new set of now (thus not requiring everyone to
remember to include it in their updates).

Change-Id: I12bac56e29cc5974d5c925f23eb94945e6e36421
This commit is contained in:
Sean Dague 2017-09-11 13:12:13 -06:00
parent c4d5e7017b
commit 7b193a0802
3 changed files with 14 additions and 4 deletions

View File

@ -27,10 +27,11 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Currently playing...</h3></div>
<table class="table">
{{#each now}}
{{#each now as |what room|}}
<tr>
<td class="col-sm-1"><span class="label label-primary {{@key}}">{{@key}}</span></td>
<td>{{#hashtag}}{{this}}{{/hashtag}}</td>
<td class="col-sm-1"><span class="label label-primary {{room}}">{{room}}</span></td>
<td>{{#hashtag}}{{what}}{{/hashtag}}</td>
<td class="col-sm-1">{{lookup @root.location room}}</td>
</tr>
{{else}}
<tr><td><small><i>Nothing yet</i></small><td></tr>

View File

@ -137,6 +137,8 @@ class PTGBot(irc.bot.SingleServerIRCBot):
self.data.clean_rooms([room])
elif adverb == 'color':
self.data.add_color(room, session)
elif adverb == 'location':
self.data.add_location(room, session)
else:
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
self.usage(chan)

View File

@ -21,7 +21,8 @@ import datetime
class PTGDataBase():
BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {}}
BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {},
'location': {}}
def __init__(self, filename, ethercalc):
self.filename = filename
@ -43,6 +44,12 @@ class PTGDataBase():
self.data['colors'][room] = color
self.save()
def add_location(self, room, location):
if 'location' not in self.data:
self.data['location'] = {}
self.data['location'][room] = location
self.save()
def add_next(self, room, session):
if room not in self.data['next']:
self.data['next'][room] = []