Add ability to book a room
Available room slots can be booked for any track through the ptgbot new #book command, referencing the slot code. Change-Id: I0c661e448568c7f2f26fb296e3f2506ba1ed44ba
This commit is contained in:
parent
0f386985fe
commit
c637840754
|
@ -19,7 +19,8 @@ You have to have voice in the channel (+v) to send commands to the ptgbot.
|
||||||
Commands follow the following format::
|
Commands follow the following format::
|
||||||
|
|
||||||
#TRACK [now|next] TOPIC
|
#TRACK [now|next] TOPIC
|
||||||
#TRACK [color] CSS_COLOR_SPECIFIER
|
#TRACK color CSS_COLOR_SPECIFIER
|
||||||
|
#TRACK book SLOT_REFERENCE
|
||||||
|
|
||||||
Please note that:
|
Please note that:
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,11 @@
|
||||||
{{#each @root.additional as |schedule room|}}
|
{{#each @root.additional as |schedule room|}}
|
||||||
<tr><td>{{room}}</td>
|
<tr><td>{{room}}</td>
|
||||||
{{#each (lookup @root.slots day) as |time|}}
|
{{#each (lookup @root.slots day) as |time|}}
|
||||||
|
{{#if (lookup schedule time.name)}}
|
||||||
<td><span class="label label-primary {{lookup schedule time.name}}">{{lookup schedule time.name}}</td>
|
<td><span class="label label-primary {{lookup schedule time.name}}">{{lookup schedule time.name}}</td>
|
||||||
|
{{else}}
|
||||||
|
<td><small><i>{{room}}-{{time.name}}</i></small></td>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
@ -119,6 +123,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
<small><i>Use #TRACK book SLOTREF to book one of those empty slots</i></small></td>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted">Content on this page is being driven by room operators through the openstackptg bot on the #openstack-ptg IRC channel. It was last refreshed on {{timestamp}}.</p>
|
<p class="text-muted">Content on this page is being driven by room operators through the openstackptg bot on the #openstack-ptg IRC channel. It was last refreshed on {{timestamp}}.</p>
|
||||||
|
|
|
@ -129,17 +129,24 @@ class PTGBot(irc.bot.SingleServerIRCBot):
|
||||||
return
|
return
|
||||||
|
|
||||||
adverb = words[1].lower()
|
adverb = words[1].lower()
|
||||||
session = str.join(' ', words[2:])
|
params = str.join(' ', words[2:])
|
||||||
if adverb == 'now':
|
if adverb == 'now':
|
||||||
self.data.add_now(track, session)
|
self.data.add_now(track, params)
|
||||||
elif adverb == 'next':
|
elif adverb == 'next':
|
||||||
self.data.add_next(track, session)
|
self.data.add_next(track, params)
|
||||||
elif adverb == 'clean':
|
elif adverb == 'clean':
|
||||||
self.data.clean_tracks([track])
|
self.data.clean_tracks([track])
|
||||||
elif adverb == 'color':
|
elif adverb == 'color':
|
||||||
self.data.add_color(track, session)
|
self.data.add_color(track, params)
|
||||||
elif adverb == 'location':
|
elif adverb == 'location':
|
||||||
self.data.add_location(track, session)
|
self.data.add_location(track, params)
|
||||||
|
elif adverb == 'book':
|
||||||
|
room, timeslot = params.split('-')
|
||||||
|
if self.data.is_slot_valid_and_empty(room, timeslot):
|
||||||
|
self.data.book(track, room, timeslot)
|
||||||
|
else:
|
||||||
|
self.send(chan, "%s: invalid slot reference '%s'" %
|
||||||
|
(nick, params))
|
||||||
else:
|
else:
|
||||||
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
|
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
|
||||||
self.usage(chan)
|
self.usage(chan)
|
||||||
|
|
10
ptgbot/db.py
10
ptgbot/db.py
|
@ -104,6 +104,16 @@ class PTGDataBase():
|
||||||
del self.data['next'][track]
|
del self.data['next'][track]
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def is_slot_valid_and_empty(self, room, timeslot):
|
||||||
|
try:
|
||||||
|
return not self.data['additional'][room][timeslot]
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def book(self, track, room, timeslot):
|
||||||
|
self.data['additional'][room][timeslot] = track
|
||||||
|
self.save()
|
||||||
|
|
||||||
def wipe(self):
|
def wipe(self):
|
||||||
self.data = self.BASE
|
self.data = self.BASE
|
||||||
self.save()
|
self.save()
|
||||||
|
|
Loading…
Reference in New Issue