[Bps-public-commit] r15083 - in sd/trunk: . lib/App/SD/CLI/Command/Ticket/Attachment lib/App/SD/CLI/Command/Ticket/Comment

spang at bestpractical.com spang at bestpractical.com
Tue Aug 12 09:32:11 EDT 2008


Author: spang
Date: Tue Aug 12 09:32:06 2008
New Revision: 15083

Modified:
   sd/trunk/   (props changed)
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm

Log:
 r47781 at loki:  spang | 2008-08-06 00:49:33 +0100
 undo that last commit


Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm	Tue Aug 12 09:32:06 2008
@@ -5,8 +5,6 @@
 
 before run => sub {
     my $self = shift;
-    $self->require_uuid;
-
     $self->set_prop(ticket => $self->cli->uuid);
 };
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm	Tue Aug 12 09:32:06 2008
@@ -8,14 +8,13 @@
 # override args to feed in that ticket's uuid as an argument to the comment
 before run => sub {
     my $self = shift;
-    $self->require_uuid;
 
     my $content = $self->get_content(type => 'comment', default_edit => 1);
 
     die "Aborted.\n"
         if length($content) == 0;
 
-    $self->set_prop(ticket => $ticket_uuid);
+    $self->set_prop(ticket => $self->cli->uuid);
     $self->set_prop(content => $content);
 };
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	Tue Aug 12 09:32:06 2008
@@ -7,16 +7,12 @@
 sub run {
     my $self = shift;
     my $record = $self->_get_record_class();
-
-    die "Cannot display comments without a ticket luid or uuid (specify with --id).\n"
-        unless (my $uuid = $self->uuid);
-
-    $record->load( uuid => $uuid );
+    $record->load( uuid => $self->uuid );
     unless (@{$record->comments}) {
         print "No comments found\n";
     }
 
-    for my $entry (sort { $a->prop('created') cmp $b->prop('created') } @{$record->comments}) {
+    for my $entry (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
          print "id: ".$entry->luid." (".$entry->uuid.")\n";
         print "created: ".$entry->prop('created')."\n";
         print $entry->prop('content')."\n";

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	Tue Aug 12 09:32:06 2008
@@ -2,8 +2,6 @@
 use Moose;
 extends 'App::SD::CLI::Command::Ticket::Show';
 
-sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
-
 override run => sub {
     my $self = shift;
     my $record = $self->_load_record;
@@ -12,12 +10,25 @@
     super();
 
     print "\n=head1 ATTACHMENTS\n\n";
-    my @attachments = sort by_creation_date @{$record->attachments};
-    print $_->format_summary . "\n" for @attachments;
+    my $attachments = App::SD::Collection::Attachment->new(
+        handle => $self->app_handle->handle,
+        app_handle => $self->app_handle,
+    );
+    $attachments->matching(sub {
+        shift->prop('ticket') eq $self->uuid ? 1 : 0;
+    });
+    print $_->format_summary . "\n" for $attachments->items;
 
     print "\n=head1 COMMENTS\n\n";
-    my @comments = sort by_creation_date @{$record->comments};
-    print $_->prop('created') . "\n" . $_->prop('content') . "\n\n" for @comments;
+    my $comments = App::SD::Collection::Comment->new(
+        handle => $self->app_handle->handle,
+    );
+    $comments->matching(sub {
+        shift->prop('ticket') eq $self->uuid ? 1 : 0;
+    });
+    my @items = sort { $a->prop('created') cmp $b->prop('created') }
+                    $comments->items;
+    print $_->prop('created') . "\n" . $_->prop('content') . "\n\n" for @items;
 };
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list