Commit 396e50bd authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Require comments when flagging packages out-of-date



Implements FS#42827.
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent 6b7e26a2
...@@ -82,6 +82,7 @@ CREATE TABLE PackageBases ( ...@@ -82,6 +82,7 @@ CREATE TABLE PackageBases (
NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0, NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0,
Popularity DECIMAL(10,6) UNSIGNED NOT NULL DEFAULT 0, Popularity DECIMAL(10,6) UNSIGNED NOT NULL DEFAULT 0,
OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL, OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL,
FlaggerComment VARCHAR(255) NOT NULL,
SubmittedTS BIGINT UNSIGNED NOT NULL, SubmittedTS BIGINT UNSIGNED NOT NULL,
ModifiedTS BIGINT UNSIGNED NOT NULL, ModifiedTS BIGINT UNSIGNED NOT NULL,
FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL, -- who flagged the package out-of-date? FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL, -- who flagged the package out-of-date?
......
...@@ -139,14 +139,15 @@ def flag(cur, uid, pkgbase_id): ...@@ -139,14 +139,15 @@ def flag(cur, uid, pkgbase_id):
user = username_from_id(cur, uid) user = username_from_id(cur, uid)
pkgbase = pkgbase_from_id(cur, pkgbase_id) pkgbase = pkgbase_from_id(cur, pkgbase_id)
to = [get_maintainer_email(cur, pkgbase_id)] to = [get_maintainer_email(cur, pkgbase_id)]
text = sys.stdin.read()
user_uri = aur_location + '/account/' + user + '/' user_uri = aur_location + '/account/' + user + '/'
pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/'
subject = 'AUR Out-of-date Notification for %s' % (pkgbase) subject = 'AUR Out-of-date Notification for %s' % (pkgbase)
body = 'Your package %s [1] has been flagged out-of-date by %s [2]. ' % \ body = 'Your package %s [1] has been flagged out-of-date by %s [2]:' % \
(pkgbase, user) (pkgbase, user)
body += '\n\n' body += '\n\n' + text + '\n\n'
body += '[1] ' + pkgbase_uri + '\n' body += '[1] ' + pkgbase_uri + '\n'
body += '[2] ' + user_uri body += '[2] ' + user_uri
......
...@@ -8,10 +8,11 @@ ALTER TABLE PackageComments ...@@ -8,10 +8,11 @@ ALTER TABLE PackageComments
ADD FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL; ADD FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL;
---- ----
2. Add a field to store the ID of the last user who flagged a package 2. Add fields to store the ID and comment of the last user who flagged a
out-of-date: package out-of-date:
---- ----
ALTER TABLE PackageBases ALTER TABLE PackageBases
ADD COLUMN FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL; ADD COLUMN FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL,
ADD COLUMN FlaggerComment VARCHAR(255) NOT NULL;
---- ----
...@@ -49,7 +49,12 @@ $output = ""; ...@@ -49,7 +49,12 @@ $output = "";
$fragment = ""; $fragment = "";
if (check_token()) { if (check_token()) {
if (current_action("do_Flag")) { if (current_action("do_Flag")) {
list($ret, $output) = pkgbase_flag($ids); if (strlen($_POST['comments']) >= 3) {
list($ret, $output) = pkgbase_flag($ids, $_POST['comments']);
} else {
$output = __("The selected packages have not been flagged, please enter a comment.");
$ret = false;
}
} elseif (current_action("do_UnFlag")) { } elseif (current_action("do_UnFlag")) {
list($ret, $output) = pkgbase_unflag($ids); list($ret, $output) = pkgbase_unflag($ids);
} elseif (current_action("do_Adopt")) { } elseif (current_action("do_Adopt")) {
......
...@@ -25,12 +25,17 @@ if (has_credential(CRED_PKGBASE_FLAG)): ?> ...@@ -25,12 +25,17 @@ if (has_credential(CRED_PKGBASE_FLAG)): ?>
<p> <p>
<?= __('Please do %snot%s use this form to report bugs. Use the package comments instead.', <?= __('Please do %snot%s use this form to report bugs. Use the package comments instead.',
'<strong>', '</strong>'); ?> '<strong>', '</strong>'); ?>
<?= __('Enter details on why the package is out-of-date below, preferably including links to the release announcement or the new release tarball.'); ?>
</p> </p>
<form action="<?= get_uri('/pkgbase/'); ?>" method="post"> <form action="<?= get_uri('/pkgbase/'); ?>" method="post">
<fieldset> <fieldset>
<input type="hidden" name="IDs[<?= $base_id ?>]" value="1" /> <input type="hidden" name="IDs[<?= $base_id ?>]" value="1" />
<input type="hidden" name="ID" value="<?= $base_id ?>" /> <input type="hidden" name="ID" value="<?= $base_id ?>" />
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
<p>
<label for="id_comments"><?= __("Comments") ?>:</label>
<textarea name="comments" id="id_comments" rows="5" cols="50"></textarea>
</p>
<p><input type="submit" class="button" name="do_Flag" value="<?= __("Flag") ?>" /></p> <p><input type="submit" class="button" name="do_Flag" value="<?= __("Flag") ?>" /></p>
</fieldset> </fieldset>
</form> </form>
......
...@@ -316,10 +316,11 @@ function pkgbase_maintainer_uids($base_ids) { ...@@ -316,10 +316,11 @@ function pkgbase_maintainer_uids($base_ids) {
* Flag package(s) as out-of-date * Flag package(s) as out-of-date
* *
* @param array $base_ids Array of package base IDs to flag/unflag * @param array $base_ids Array of package base IDs to flag/unflag
* @param string $comment The comment to add
* *
* @return array Tuple of success/failure indicator and error message * @return array Tuple of success/failure indicator and error message
*/ */
function pkgbase_flag($base_ids) { function pkgbase_flag($base_ids, $comment) {
if (!has_credential(CRED_PKGBASE_FLAG)) { if (!has_credential(CRED_PKGBASE_FLAG)) {
return array(false, __("You must be logged in before you can flag packages.")); return array(false, __("You must be logged in before you can flag packages."));
} }
...@@ -332,14 +333,15 @@ function pkgbase_flag($base_ids) { ...@@ -332,14 +333,15 @@ function pkgbase_flag($base_ids) {
$uid = uid_from_sid($_COOKIE['AURSID']); $uid = uid_from_sid($_COOKIE['AURSID']);
$dbh = DB::connect(); $dbh = DB::connect();
$q = "UPDATE PackageBases SET"; $q = "UPDATE PackageBases SET ";
$q.= " OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid; $q.= "OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid . ", ";
$q.= " WHERE ID IN (" . implode(",", $base_ids) . ")"; $q.= "FlaggerComment = " . $dbh->quote($comment) . " ";
$q.= " AND OutOfDateTS IS NULL"; $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
$q.= "AND OutOfDateTS IS NULL";
$dbh->exec($q); $dbh->exec($q);
foreach ($base_ids as $base_id) { foreach ($base_ids as $base_id) {
notify(array('flag', $uid, $base_id)); notify(array('flag', $uid, $base_id), $comment);
} }
return array(true, __("The selected packages have been flagged out-of-date.")); return array(true, __("The selected packages have been flagged out-of-date."));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment