mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Factoids: Fix @lock and @unlock.
This commit is contained in:
parent
c133d973aa
commit
b9a46cef21
@ -583,10 +583,10 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("UPDATE factoids, keys, relations "
|
||||
"SET factoids.locked=1 WHERE key LIKE ? AND "
|
||||
"factoids.id=relations.fact_id AND "
|
||||
"keys.id=relations.key_id", (key,))
|
||||
cursor.execute("UPDATE factoids "
|
||||
"SET locked=1 WHERE factoids.id IN "
|
||||
"(SELECT fact_id FROM relations WHERE key_id IN "
|
||||
"(SELECT id FROM keys WHERE key LIKE ?));", (key,))
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
lock = wrap(lock, ['channel', 'text'])
|
||||
@ -601,10 +601,10 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""UPDATE factoids, keys, relations
|
||||
SET factoids.locked=1 WHERE key LIKE ? AND
|
||||
factoids.id=relations.fact_id AND
|
||||
keys.id=relations.key_id""", (key,))
|
||||
cursor.execute("UPDATE factoids "
|
||||
"SET locked=0 WHERE factoids.id IN "
|
||||
"(SELECT fact_id FROM relations WHERE key_id IN "
|
||||
"(SELECT id FROM keys WHERE key LIKE ?));", (key,))
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
unlock = wrap(unlock, ['channel', 'text'])
|
||||
|
@ -208,4 +208,10 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('learn foo as "\\"bar\\""')
|
||||
self.assertRegexp('whatis foo', r'"bar"')
|
||||
|
||||
def testLock(self):
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertNotError('lock foo')
|
||||
self.assertNotError('unlock foo')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
Loading…
Reference in New Issue
Block a user