[Bps-public-commit] r20133 - in RT-BugTracker: lib/RT/Action

ruz at bestpractical.com ruz at bestpractical.com
Mon Nov 23 18:08:41 EST 2009


Author: ruz
Date: Mon Nov 23 18:08:41 2009
New Revision: 20133

Modified:
   RT-BugTracker/html/Dist/Elements/EditNotes
   RT-BugTracker/html/Dist/Elements/EditNotifyAddresses
   RT-BugTracker/html/Dist/Elements/ShowNotes
   RT-BugTracker/lib/RT/Action/NotifyAdditionalAddresses.pm

Log:
* switch over new API for attributes based fields

Modified: RT-BugTracker/html/Dist/Elements/EditNotes
==============================================================================
--- RT-BugTracker/html/Dist/Elements/EditNotes	(original)
+++ RT-BugTracker/html/Dist/Elements/EditNotes	Mon Nov 23 18:08:41 2009
@@ -4,9 +4,7 @@
 $Queue => undef
 </%ARGS>
 <%INIT>
-my $value = $Queue->FirstAttribute('DistributionNotes');
-$value = $value->Content if $value;
-$value = '' unless defined $value;
+my $value = $Queue->DistributionNotes;
 </%INIT>
 
 <%METHOD Process>
@@ -15,33 +13,11 @@
 </%ARGS>
 <%INIT>
 return () unless exists $ARGS{'Queue-'. $Queue->id .'-Notes'};
+
 my $value = $ARGS{'Queue-'. $Queue->id .'-Notes'};
 $value = $m->comp('/Elements/ScrubHTML', Content => $value );
 
-my ($status, $msg, $result);
-if ( defined $value && length $value ) {
-    ($status, $msg) = $Queue->SetAttribute(
-        Name        => 'DistributionNotes',
-        Description => 'A html block with distribution notes',
-        Content     => $value,
-    );
-    $RT::Logger->error("Couldn't set attribute: $msg")
-        unless $status;
-
-    $result = loc("Updated distribution notes");
-} else {
-    return () unless $Queue->FirstAttribute( 'DistributionNotes' );
-
-    ($status, $msg) = $Queue->DeleteAttribute( 'DistributionNotes' );
-    $RT::Logger->error("Couldn't delete attribute: $msg")
-        unless $status;
-
-    $result = loc("Deleted distribution notes");
-}
-return loc("System error. Couldn't set notes for the distribution.")
-    unless $status;
-
-return $result;
-
+my ($status, $msg) = $Queue->SetDistributionNotes( $value );
+return $msg;
 </%INIT>
 </%METHOD>

Modified: RT-BugTracker/html/Dist/Elements/EditNotifyAddresses
==============================================================================
--- RT-BugTracker/html/Dist/Elements/EditNotifyAddresses	(original)
+++ RT-BugTracker/html/Dist/Elements/EditNotifyAddresses	Mon Nov 23 18:08:41 2009
@@ -4,9 +4,7 @@
 $Queue => undef
 </%ARGS>
 <%INIT>
-my $value = $Queue->FirstAttribute('NotifyAddresses');
-$value = $value->Content if $value;
-$value ||= [];
+my $value = $Queue->NotifyAddresses;
 </%INIT>
 
 <%METHOD Process>
@@ -17,32 +15,12 @@
 return () unless exists $ARGS{'Queue-'. $Queue->id .'-NotifyAddresses'};
 my $value = $ARGS{'Queue-'. $Queue->id .'-NotifyAddresses'};
 
-my @addrs = grep /\@/, map $_->address, grep defined, Mail::Address->parse( $value );
-
-my ($status, $msg, $result);
-if ( @addrs ) {
-    ($status, $msg) = $Queue->SetAttribute(
-        Name        => 'NotifyAddresses',
-        Description => 'List of addresses we should notify',
-        Content     => \@addrs,
-    );
-    $RT::Logger->error("Couldn't set attribute: $msg")
-        unless $status;
-
-    $result = loc("Updated list of additional addresses RT should notify");
-} else {
-    return () unless $Queue->FirstAttribute( 'NotifyAddresses' );
-
-    ($status, $msg) = $Queue->DeleteAttribute( 'NotifyAddresses' );
-    $RT::Logger->error("Couldn't delete attribute: $msg")
-        unless $status;
-
-    $result = loc("Deleted all additional addresses");
-}
-return loc("System error. Couldn't set addresses.")
-    unless $status;
-
-return $result;
+my @addrs = grep /\@/, map $_->address, grep defined,
+    Mail::Address->parse( $value );
 
+my ($status, $msg) = $Queue->SetNotifyAddresses(
+    @addrs? \@addrs : undef
+);
+return $msg;
 </%INIT>
 </%METHOD>

Modified: RT-BugTracker/html/Dist/Elements/ShowNotes
==============================================================================
--- RT-BugTracker/html/Dist/Elements/ShowNotes	(original)
+++ RT-BugTracker/html/Dist/Elements/ShowNotes	Mon Nov 23 18:08:41 2009
@@ -4,7 +4,7 @@
 <p>This queue has been disabled by maintainers' request. Heh, it's still possible to create bugs using email address, but we <b>beg you</b> "don't create new tickets". Instead read distribution's documentation and figure out how to report issues properly.</p>
 % }
 
-% if ( defined $notes ) {
+% if ( defined $notes && length $notes ) {
 <h3><% loc("Maintainer(s)' notes") %></h3>
 
 <p><% $notes |n %></p>
@@ -14,7 +14,5 @@
 $Queue
 </%ARGS>
 <%INIT>
-my $notes = $Queue->FirstAttribute( 'DistributionNotes' );
-$notes = $notes->Content if $notes;
-$notes = undef if defined $notes && !length $notes;
+my $notes = $Queue->DistributionNotes;
 </%INIT>

Modified: RT-BugTracker/lib/RT/Action/NotifyAdditionalAddresses.pm
==============================================================================
--- RT-BugTracker/lib/RT/Action/NotifyAdditionalAddresses.pm	(original)
+++ RT-BugTracker/lib/RT/Action/NotifyAdditionalAddresses.pm	Mon Nov 23 18:08:41 2009
@@ -18,11 +18,8 @@
 
 sub SetRecipients {
     my $self = shift;
-    my $attr = $self->TicketObj->QueueObj->FirstAttribute('NotifyAddresses');
-    return unless $attr;
-    my $addresses = $attr->Content;
+    my $addresses = $self->TicketObj->QueueObj->NotifyAddresses;
     return unless $addresses && @$addresses;
-
     $self->{'To'} = [ @$addresses ];
 }
 



More information about the Bps-public-commit mailing list