|
@@ -174,7 +174,7 @@ class DRNClerkBot(Task): |
|
|
|
|
|
|
|
|
def read_page(self, conn, cases, text): |
|
|
def read_page(self, conn, cases, text): |
|
|
"""Read the noticeboard content and update the list of _Cases.""" |
|
|
"""Read the noticeboard content and update the list of _Cases.""" |
|
|
nextid = self.select_next_id(conn, "case_id", "cases") |
|
|
|
|
|
|
|
|
nextid = self.select_next_id(conn) |
|
|
tl_status_esc = re.escape(self.tl_status) |
|
|
tl_status_esc = re.escape(self.tl_status) |
|
|
split = re.split("(^==\s*[^=]+?\s*==$)", text, flags=re.M|re.U) |
|
|
split = re.split("(^==\s*[^=]+?\s*==$)", text, flags=re.M|re.U) |
|
|
for i in xrange(len(split)): |
|
|
for i in xrange(len(split)): |
|
@@ -217,14 +217,14 @@ class DRNClerkBot(Task): |
|
|
case.title = title |
|
|
case.title = title |
|
|
case.body, case.old = body, old |
|
|
case.body, case.old = body, old |
|
|
|
|
|
|
|
|
def select_next_id(self, conn, column, table): |
|
|
|
|
|
|
|
|
def select_next_id(self, conn): |
|
|
"""Return the next incremental ID for a case.""" |
|
|
"""Return the next incremental ID for a case.""" |
|
|
query = "SELECT MAX(?) FROM {0}".format(table) |
|
|
|
|
|
|
|
|
query = "SELECT MAX(case_id) FROM cases" |
|
|
with conn.cursor() as cursor: |
|
|
with conn.cursor() as cursor: |
|
|
cursor.execute(query, (column,)) |
|
|
|
|
|
|
|
|
cursor.execute(query) |
|
|
current = cursor.fetchone()[0] |
|
|
current = cursor.fetchone()[0] |
|
|
if current: |
|
|
if current: |
|
|
return current + 1 |
|
|
|
|
|
|
|
|
return int(current) + 1 |
|
|
return 1 |
|
|
return 1 |
|
|
|
|
|
|
|
|
def read_status(self, body): |
|
|
def read_status(self, body): |
|
@@ -418,18 +418,16 @@ class DRNClerkBot(Task): |
|
|
|
|
|
|
|
|
with conn.cursor() as cursor: |
|
|
with conn.cursor() as cursor: |
|
|
query1 = "DELETE FROM signatures WHERE signature_case = ? AND signature_username = ? AND signature_timestamp = ?" |
|
|
query1 = "DELETE FROM signatures WHERE signature_case = ? AND signature_username = ? AND signature_timestamp = ?" |
|
|
query2 = "INSERT INTO signatures VALUES (?, ?, ?, ?)" |
|
|
|
|
|
|
|
|
query2 = "INSERT INTO signatures (signature_case, signature_username, signature_timestamp) VALUES (?, ?, ?)" |
|
|
removals = set(storedsigs) - set(sigs) |
|
|
removals = set(storedsigs) - set(sigs) |
|
|
additions = set(sigs) - set(storedsigs) |
|
|
additions = set(sigs) - set(storedsigs) |
|
|
if removals: |
|
|
if removals: |
|
|
args = [(case.id, name, stamp) for (name, stamp) in removals] |
|
|
args = [(case.id, name, stamp) for (name, stamp) in removals] |
|
|
cursor.executemany(query1, args) |
|
|
cursor.executemany(query1, args) |
|
|
if additions: |
|
|
if additions: |
|
|
nextid = self.select_next_id(conn, "signature_id", "signatures") |
|
|
|
|
|
args = [] |
|
|
args = [] |
|
|
for name, stamp in additions: |
|
|
for name, stamp in additions: |
|
|
args.append((nextid, case.id, name, stamp)) |
|
|
|
|
|
nextid += 1 |
|
|
|
|
|
|
|
|
args.append((case.id, name, stamp)) |
|
|
cursor.executemany(query2, args) |
|
|
cursor.executemany(query2, args) |
|
|
|
|
|
|
|
|
def save_new_case(self, conn, case): |
|
|
def save_new_case(self, conn, case): |
|
|