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:
parent
c4d5e7017b
commit
7b193a0802
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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] = []
|
||||
|
|
Loading…
Reference in New Issue