[bugzilla-gnome-org-extensions] splinter: Port to GnomeAttachmentStatus
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] splinter: Port to GnomeAttachmentStatus
- Date: Thu, 20 Nov 2014 22:27:45 +0000 (UTC)
commit f1563b74f1f022b1195e322a2afb023488a59c86
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Tue Nov 18 23:26:47 2014 +0100
splinter: Port to GnomeAttachmentStatus
Splinter/Extension.pm | 4 ++++
Splinter/lib/Ops.pm | 12 +++---------
Splinter/lib/WebService.pm | 33 +++++----------------------------
Splinter/web/splinter.js | 3 ++-
4 files changed, 14 insertions(+), 38 deletions(-)
---
diff --git a/Splinter/Extension.pm b/Splinter/Extension.pm
index d143b5e..1b0b9b6 100644
--- a/Splinter/Extension.pm
+++ b/Splinter/Extension.pm
@@ -73,4 +73,8 @@ sub webservice {
add_dispatch($dispatches);
}
+sub gnome_deps {
+ ('GnomeAttachmentStatus');
+}
+
__PACKAGE__->NAME;
diff --git a/Splinter/lib/Ops.pm b/Splinter/lib/Ops.pm
index b77d6cd..006724e 100644
--- a/Splinter/lib/Ops.pm
+++ b/Splinter/lib/Ops.pm
@@ -169,15 +169,9 @@ sub maybe_setup_vars_for_page {
my ($page, $vars) = @_;
if ($page eq 'splinter.html') {
- # We do this in a way that is safe if the Bugzilla instance doesn't
- # have an attachments.status field (which is a bugzilla.gnome.org
- # addition)
- my $field_object = Bugzilla::Field->new({ name => 'attachments.status' });
- my @statuses = ();
-
- if ($field_object) {
- @statuses = map { $_->name } @{ $field_object->legal_values };
- }
+ my $field_object = Bugzilla::Field->new({ name => 'attachments.gnome_attachment_status' });
+ my @statuses = map { $_->name } @{ $field_object->legal_values() };
+
$vars->{'attachment_statuses'} = \ statuses;
$vars->{'urlbase'} = correct_urlbase();
}
diff --git a/Splinter/lib/WebService.pm b/Splinter/lib/WebService.pm
index 855b5fc..fdff6aa 100644
--- a/Splinter/lib/WebService.pm
+++ b/Splinter/lib/WebService.pm
@@ -59,9 +59,9 @@ sub publish_review {
my $attachment_status = $params->{'attachment_status'};
if (defined($attachment_status)) {
- my $field_object = Bugzilla::Field->new({ name => 'attachments.status' });
+ my $field_object = Bugzilla::Field->new({ name => 'attachments.gnome_attachment_status' });
my @legal_values = map { $_->name } @{ $field_object->legal_values() };
- check_field('attachments.status', $attachment_status, \ legal_values);
+ check_field('attachments.gnome_attachment_status', $attachment_status, \ legal_values);
}
my $attachment = Bugzilla::Attachment->new($params->{'attachment_id'});
@@ -90,32 +90,9 @@ sub publish_review {
$bug->add_comment($comment);
$dbh->bz_start_transaction();
- if (defined($attachment_status) && $attachment->status() ne $attachment_status) {
- # Note that this file needs to load properly even if the installation
- # doesn't have attachment statuses (a bugzilla.gnome.org addition), so,
- # for example, we wouldn't want an explicit 'use Bugzilla::AttachmentStatus'
-
- # Update the attachment record in the database.
- $dbh->do("UPDATE attachments
- SET status = ?,
- modification_time = ?
- WHERE attach_id = ?",
- undef, ($attachment_status, $timestamp, $attachment->id()));
-
- my $updated_attachment = Bugzilla::Attachment->new($attachment->id());
-
- if ($attachment->status() ne $updated_attachment->status()) {
- my $fieldid = get_field_id('attachments.status');
-
- $dbh->do('INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when,
- fieldid, removed, added)
- VALUES (?, ?, ?, ?, ?, ?, ?)',
- undef, ($bug->id(), $attachment->id, $user->id(),
- $timestamp, $fieldid,
- $attachment->status(), $updated_attachment->status()));
-
- # Adding the comment will update the bug's delta_ts, so we don't need to do it here
- }
+ if (defined($attachment_status) && $attachment->gnome_attachment_status() ne $attachment_status) {
+ $attachment->set_gnome_attachment_status($attachment_status);
+ $attachment->update();
}
# This actually adds the comment
diff --git a/Splinter/web/splinter.js b/Splinter/web/splinter.js
index 7a5b87a..3ff0559 100644
--- a/Splinter/web/splinter.js
+++ b/Splinter/web/splinter.js
@@ -212,6 +212,7 @@ Bug.Bug.fromDOM = function(xml) {
attachment.isPatch = $(this).attr('ispatch') == "1";
attachment.isObsolete = $(this).attr('isobsolete') == "1";
attachment.isPrivate = $(this).attr('isprivate') == "1";
+ attachment.status = Utils.strip($(this).children('gnome_attachment_status').text());
bug.attachments.push(attachment);
});
@@ -1542,7 +1543,7 @@ function updateAttachmentStatus(attachment, newStatus, success, failure) {
ispatch: attachment.isPatch ? 1 : 0,
isobsolete: attachment.isObsolete ? 1 : 0,
isprivate: attachment.isPrivate ? 1 : 0,
- 'attachments.status': newStatus
+ 'attachments.gnome_attachment_status': newStatus
};
if (attachment.token)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]