From: Joerg Jaspert Date: Wed, 15 Apr 2009 21:08:41 +0000 (+0200) Subject: process-new X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48e5e5ee12f7c36e3272ec8d3dc0d6c43625d984;p=dak process-new notes now have a timestamp column. do not allow to edit old notes, only add new ones hand over existing notes (if any) to the reject message (unless we get called with -m) hand over existing notes (if any) to the prod message Signed-off-by: Joerg Jaspert --- diff --git a/dak/dakdb/update12.py b/dak/dakdb/update12.py new file mode 100755 index 00000000..70a9e18e --- /dev/null +++ b/dak/dakdb/update12.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# coding=utf8 + +""" +Adding a date field to the process-new notes + +@contact: Debian FTP Master +@copyright: 2009 Joerg Jaspert +@license: GNU General Public License version 2 or later +""" + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + + +################################################################################ + +import psycopg2 +import time + +################################################################################ + +def do_update(self): + print "Adding a date field to the process-new notes" + + try: + c = self.db.cursor() + c.execute("ALTER TABLE new_comments ADD COLUMN notedate TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()") + + c.execute("UPDATE config SET value = '12' WHERE name = 'db_revision'") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to apply process-new update 12, rollback issued. Error message : %s" % (str(msg)) diff --git a/dak/process_new.py b/dak/process_new.py index 8f3ad0cf..2c0f452f 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -469,19 +469,14 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file (fd, temp_filename) = utils.temp_filename() - temp_file = os.fdopen(fd, 'w') - if len(note) > 0: - for line in note: - temp_file.write(line) - temp_file.close() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) temp_file = utils.open_file(temp_filename) - note = temp_file.read().rstrip() + newnote = temp_file.read().rstrip() temp_file.close() - print "Note:" + print "New Note:" print utils.prefix_multi_line_string(note," ") prompt = "[D]one, Edit, Abandon, Quit ?" answer = "XXX" @@ -689,14 +684,16 @@ def do_new(): elif answer == 'E' and not Options["Trainee"]: new = edit_overrides (new) elif answer == 'M' and not Options["Trainee"]: - aborted = Upload.do_reject(1, Options["Manual-Reject"]) + aborted = Upload.do_reject(manual=1, + reject_message=Options["Manual-Reject"], + note=database.get_new_comments(changes.get("source", ""))) if not aborted: os.unlink(Upload.pkg.changes_file[:-8]+".dak") done = 1 elif answer == 'N': edit_note(database.get_new_comments(changes.get("source", ""))) elif answer == 'P' and not Options["Trainee"]: - prod_maintainer() + prod_maintainer(database.get_new_comments(changes.get("source", ""))) elif answer == 'R': confirm = utils.our_raw_input("Really clear note (y/N)? ").lower() if confirm == "y": diff --git a/dak/update_db.py b/dak/update_db.py index 89dab5cd..b559e544 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -45,7 +45,7 @@ from daklib.dak_exceptions import DBUpdateError Cnf = None projectB = None -required_database_schema = 11 +required_database_schema = 12 ################################################################################ diff --git a/daklib/database.py b/daklib/database.py index dbfa2af7..a995378b 100755 --- a/daklib/database.py +++ b/daklib/database.py @@ -851,12 +851,14 @@ def get_new_comments(package): """ comments = [] - query = projectB.query(""" SELECT version, comment, author + query = projectB.query(""" SELECT version, comment, author, notedate FROM new_comments - WHERE package = '%s' """ % (package)) + WHERE package = '%s' + ORDER BY notedate + """ % (package)) for row in query.getresult(): - comments.append("\nAuthor: %s\nVersion: %s\n\n%s\n" % (row[2], row[0], row[1])) + comments.append("\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s\n" % (row[2], row[0], row[4], row[1])) comments.append("-"*72) return comments diff --git a/daklib/queue.py b/daklib/queue.py index 599b077f..35754c8d 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -803,7 +803,7 @@ distribution.""" ########################################################################### - def do_reject (self, manual = 0, reject_message = ""): + def do_reject (self, manual = 0, reject_message = "", note = ""): """ Reject an upload. If called without a reject message or C{manual} is true, spawn an editor so the user can write one. @@ -821,6 +821,11 @@ distribution.""" # editor so the user can add one in... if manual and not reject_message: (fd, temp_filename) = utils.temp_filename() + temp_file = os.fdopen(fd, 'w') + if len(note) > 0: + for line in note: + temp_file.write(line) + temp_file.close() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E':