[Bps-public-commit] RT-BugTracker branch, alternate-bugtracker, created. 34d66c64eaeaff6d0863bfe787e966f94af675cc

Thomas Sibley trs at bestpractical.com
Tue Mar 12 22:25:35 EDT 2013


The branch, alternate-bugtracker has been created
        at  34d66c64eaeaff6d0863bfe787e966f94af675cc (commit)

- Log -----------------------------------------------------------------
commit d8ebc7bd839a746fd955010c865fac4f5c10e91c
Author: Ian Norton <i.norton at shadowcat.co.uk>
Date:   Tue Mar 12 18:22:28 2013 -0700

    Show distribution notes on ticket display and modify [rt.cpan.org #79499]
    
    This gives distribution authors more visibility for their notes.
    
    Signed-off-by: Thomas Sibley <trs at bestpractical.com>

diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList
new file mode 100644
index 0000000..816deeb
--- /dev/null
+++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList
@@ -0,0 +1,6 @@
+<%ARGS>
+$Ticket
+</%ARGS>
+
+<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &>
+
diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList
new file mode 100644
index 0000000..816deeb
--- /dev/null
+++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList
@@ -0,0 +1,6 @@
+<%ARGS>
+$Ticket
+</%ARGS>
+
+<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &>
+

commit 34d66c64eaeaff6d0863bfe787e966f94af675cc
Author: Ian Norton <i.norton at shadowcat.co.uk>
Date:   Tue Mar 12 18:26:19 2013 -0700

    Display alternate bug tracker info for a distribution, if available [rt.cpan.org #79499]
    
    This patch adds support for displaying the information added by cpan2rt in
    rt.cpan.org ticket #80020.
    
    Whilst we don't prevent creation of tickets in a queue with an external bug
    tracker set, we strongly suggest that they might want to look at the
    alternative tracking solution indicated.  Should this be unavailable, this
    still enables creation of tickets within rt.cpan.org as a last resort.
    
    This work has been sponsored by Shadowcat Systems.
    
    [TRS: I simplified the CSS handling for RT 4.]
    
    Signed-off-by: Thomas Sibley <trs at bestpractical.com>

diff --git a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart
index e8073a5..f68d289 100644
--- a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart
+++ b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart
@@ -2,5 +2,7 @@
 $QueueObj
 </%ARGS>
 
+<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &>
+
 <& /Dist/Elements/ShowNotes, Queue => $QueueObj &>
 
diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList
index 816deeb..8b8d82f 100644
--- a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList
+++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList
@@ -2,5 +2,7 @@
 $Ticket
 </%ARGS>
 
+<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &>
+
 <& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &>
 
diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList
index 816deeb..8b8d82f 100644
--- a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList
+++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList
@@ -2,5 +2,7 @@
 $Ticket
 </%ARGS>
 
+<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &>
+
 <& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &>
 
diff --git a/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList
new file mode 100644
index 0000000..51854cc
--- /dev/null
+++ b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList
@@ -0,0 +1,6 @@
+<%ARGS>
+$Ticket
+</%ARGS>
+
+<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &>
+
diff --git a/html/Dist/Display.html b/html/Dist/Display.html
index 78edcec..eff3c47 100755
--- a/html/Dist/Display.html
+++ b/html/Dist/Display.html
@@ -52,6 +52,8 @@
 
 <& /Elements/Tabs &>
 
+<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &>
+
 <& /Dist/Elements/ShowNotes, Queue => $QueueObj &>
 
 <& /Dist/Elements/ShowMaintainers, Queue => $QueueObj &>
diff --git a/html/Dist/Elements/ShowBugtracker b/html/Dist/Elements/ShowBugtracker
new file mode 100644
index 0000000..1c9a434
--- /dev/null
+++ b/html/Dist/Elements/ShowBugtracker
@@ -0,0 +1,24 @@
+% if ( defined $bugtracker ) {
+<div id="external_bugtracker">
+<h3><% loc("Alternative bug tracker") %></h3>
+%
+% if ( defined $bugtracker->{mailto} ) {
+<p>
+<div>Please email the <a href="mailto:<% $bugtracker->{mailto} %>">alternative bug tracker</a> to report your issue.</div>
+</p>
+% }
+%
+% if ( defined $bugtracker->{web} ) {
+<p>
+<div>Please visit the <a href="<% $bugtracker->{web} %>">alternative bug tracker</a> to report your issue.</div>
+</p>
+% }
+</div>
+% }
+%
+<%ARGS>
+$Queue
+</%ARGS>
+<%INIT>
+my $bugtracker = $Queue->DistributionBugtracker;
+</%INIT>
diff --git a/html/NoAuth/css/bugtracker.css b/html/NoAuth/css/bugtracker.css
new file mode 100644
index 0000000..6f68fea
--- /dev/null
+++ b/html/NoAuth/css/bugtracker.css
@@ -0,0 +1,12 @@
+#external_bugtracker {
+    width: 50%;
+    border: 1px solid #666;
+    background: #ffffaa 8px 15px no-repeat;
+    padding: 0px 10px 10px 60px;
+    margin: 20px auto;
+    min-height: 30px;
+    -webkit-box-shadow: inset 2px 2px 2px 2px #999;
+    box-shadow: inset 2px 2px 2px 2px #999;
+    -webkit-border-radius: 10px;
+    border-radius: 10px;
+}
diff --git a/lib/RT/BugTracker.pm b/lib/RT/BugTracker.pm
index 9121a02..b977f06 100644
--- a/lib/RT/BugTracker.pm
+++ b/lib/RT/BugTracker.pm
@@ -82,9 +82,72 @@ overriden. We currently in sync with RT 3.6.6.
 
 =cut
 
+RT->AddStyleSheets("bugtracker.css");
+
 require RT::Queue;
 package RT::Queue;
 
+sub DistributionBugtracker {
+    return (shift)->_AttributeBasedField(
+        DistributionBugtracker => @_
+    );
+}
+
+
+sub SetDistributionBugtracker {
+    my ($self, $value) = (shift, shift);
+
+    my $bugtracker = {};
+    my $update = 0;
+
+    # Validate and set the mail to - we don't care if this is rt.cpan.org
+    if(defined($value->{mailto}) && !($value->{mailto} =~  m/rt\.cpan\.org/)) {
+        if(Email::Address->parse($value->{mailto})) {
+            $bugtracker->{mailto} = $value->{mailto};
+            $update = 1;
+        }
+    }
+
+    # Hash of supported URI schemes for validation
+    my $supported_schemes = {
+        http    => 1,
+        https   => 1,
+    };
+
+    # Validate and set the web - we don't care if this is rt.cpan.org
+    if(defined($value->{web}) && !($value->{web} =~ m/rt\.cpan\.org/)) {
+        if(my $uri = URI->new($value->{web})) {
+
+            # Check that this is a supported scheme
+            if(defined($supported_schemes->{$uri->scheme()})) {
+                $bugtracker->{web} = $value->{web};
+                $update = 1;
+            }
+
+            else {
+                my $error_msg = "Failed to set external bugtracker website";
+                $error_msg   .= " on distribution (" . $self->Name() .  ").";
+                $error_msg   .= " Unsupported scheme (" . $uri->scheme() . ").";
+                $RT::Logger->error($error_msg);
+            }
+        }
+        else {
+            my $error_msg = "Failed to set external bugtracker website";
+            $error_msg   .= " on distribution (" . $self->Name() .  ")";
+            $error_msg   .= " Unable to parse (" . $value->{web} . ") with URI.";
+            $RT::Logger->error($error_msg);
+        }
+    }
+
+    if($update) {
+        return $self->_SetAttributeBasedField( DistributionBugtracker => $bugtracker );
+    }
+
+    else {
+        return $self->_SetAttributeBasedField( DistributionBugtracker => undef );
+    }
+}
+
 sub DistributionNotes {
     return (shift)->_AttributeBasedField(
         DistributionNotes => @_

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list