Make 'unbook' available for all

The ability to unbook rooms should be accessible to all users.

Change-Id: If747141f9cfc1cd74b542071a798cf94ff1db309
This commit is contained in:
Thierry Carrez 2018-11-26 14:05:08 +01:00
parent 894c8672e8
commit 57d849493b
3 changed files with 27 additions and 8 deletions

View File

@ -79,6 +79,15 @@ you can use book the room. Example usage::
you can use the ``now`` and ``next`` commands to communicate what topic
is being discussed.
unbook
------
The ``unbook`` command is used to free up booked slots in the additional rooms.
You should generally not unbook a track without the consent of its track lead.
Example usage::
#vitrage unbook Missouri-MonAM
clean
-----
@ -127,9 +136,6 @@ You have to be a channel operator (+o) to use admin commands.
~clean TRACK [TRACK..]
Removes active entries for specified track(s)
~unbook SLOTCODE
Removes any booking at the slot named SLOTCODE
~newday
Removes now/next/location entries, to be run at the start of a new day

View File

@ -140,8 +140,19 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot):
self.send(chan, "%s: Room %s is now booked on %s for %s" %
(nick, room, timeslot, track))
else:
self.send(chan, "%s: invalid slot reference '%s'" %
self.send(chan, "%s: slot '%s' is invalid (or booked)" %
(nick, params))
elif adverb == 'unbook':
room, sep, timeslot = params.partition('-')
if self.data.is_slot_booked_for_track(track, room, timeslot):
self.data.unbook(room, timeslot)
self.send(chan, "%s: Room %s (previously booked for %s) "
"is now free on %s" %
(nick, room, track, timeslot))
else:
self.send(chan, "%s: slot '%s' is invalid "
"(or not booked for %s)" %
(nick, params, track))
else:
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
self.usage(chan)
@ -163,10 +174,6 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot):
self.send(chan, "Done.")
except Exception as e:
self.send(chan, "Error loading DB: %s" % e)
elif command == 'unbook':
params = str.join(' ', words[1:])
room, sep, timeslot = params.partition('-')
self.data.unbook(room, timeslot)
elif command == 'newday':
self.data.new_day_cleanup()
elif command == 'requirevoice':

View File

@ -138,6 +138,12 @@ class PTGDataBase():
except KeyError:
return False
def is_slot_booked_for_track(self, track, room, timeslot):
try:
return self.data['schedule'][room][timeslot] == track
except KeyError:
return False
def book(self, track, room, timeslot):
self.data['schedule'][room][timeslot] = track
self.save()