[Bps-public-commit] r16397 - in sd/trunk/lib/App/SD: CLI

jesse at bestpractical.com jesse at bestpractical.com
Mon Oct 20 12:57:48 EDT 2008


Author: jesse
Date: Mon Oct 20 12:57:47 2008
New Revision: 16397

Modified:
   sd/trunk/lib/App/SD/CLI/Dispatcher.pm
   sd/trunk/lib/App/SD/Model/Ticket.pm

Log:
* Milestone validation

Modified: sd/trunk/lib/App/SD/CLI/Dispatcher.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Dispatcher.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Dispatcher.pm	Mon Oct 20 12:57:47 2008
@@ -15,6 +15,14 @@
 on qr'^help ticket (list|search|find)$' => sub { run('help search', @_); last_rule;};
 on qr'^help (?:list|find)$' => sub { run('help search', @_); last_rule;};
 
+on qr{ticket \s+ give \s+ (.*) \s+ (.*)}xi => sub {
+    my %args = @_;
+    $args{context}->set_arg(type => 'ticket');
+    $args{context}->set_arg(id => $1);
+    $args{context}->set_arg(owner => $2);
+    run('update', %args);
+};
+
 # allow type to be specified via primary commands, e.g.
 # 'sd ticket display --id 14' -> 'sd display --type ticket --id 14'
 on qr{^(ticket|comment|attachment) \s+ (.*)}xi => sub {
@@ -23,7 +31,6 @@
     run($2, %args);
 };
 
-
 #on qr'^about$' => sub { run('help about'); last_rule;};
 
 
@@ -40,8 +47,7 @@
         my @pieces = __PACKAGE__->resolve_builtin_aliases(@$_);
 
         while (@pieces) {
-            push @possible_classes, "App::SD::CLI::Command::"
-                                . join '::', @pieces;
+            push @possible_classes, "App::SD::CLI::Command::" . join '::', @pieces;
             shift @pieces;
         }
     }

Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm	Mon Oct 20 12:57:47 2008
@@ -15,6 +15,10 @@
 =cut
 
 
+sub default_prop_milestone { 
+    my $self = shift; 
+    return $self->app_handle->setting(label => 'default_milestone')->get()->[0];
+}
 
 sub default_prop_status { 
     my $self = shift; 
@@ -77,19 +81,28 @@
 
 sub validate_prop_status {
     my ( $self, %args ) = @_;
+    return $self->_validate_prop_from_setting('status', 'statuses', \%args);
+}
+
+
+sub validate_prop_milestone {
+    my ( $self, %args ) = @_;
+    return $self->_validate_prop_from_setting('milestone', 'milestones', \%args);
+}
 
-    # XXX: validater not called when a value is unset, so can't do
-    # mandatory check here
 
-    return 1
-        if scalar grep { $args{props}{status} eq $_ }
-            @{ $self->app_handle->setting( label => 'statuses' )->get() };
+sub _validate_prop_from_setting {
+    my ( $self, $prop, $setting, $args ) = @_;
+    # XXX: validater not called when a value is unset, so can't do mandatory check here
+    return 1 if scalar grep { $args->{props}{$prop} eq $_ }
+            @{ $self->app_handle->setting( label => $setting )->get() };
 
-    $args{errors}{status} = "'" . $args{props}->{status} . "' is not a valid status";
+    $args->{errors}{$prop} = "'" . $args->{props}->{$prop} . "' is not a valid $prop";
     return 0;
-
 }
 
+
+
 =head2 color_prop_status $value
 
 Returns the stats prop value C<$value> wrapped in colorization escape



More information about the Bps-public-commit mailing list