diff options
author | Francois Marier <francois@debian.org> | 2008-06-29 21:51:31 +1200 |
---|---|---|
committer | Francois Marier <francois@debian.org> | 2008-06-29 21:51:31 +1200 |
commit | 03a60521d41962fb3d36e8e8002e9bba51796ff6 (patch) | |
tree | 36150e8a410695002674e5ad202c425d1796b0c9 /lib/CIL/Issue.pm | |
parent | 42280f662d3ce4affb00eb68a22a081dfb951395 (diff) |
Imported Upstream version v0.3.0upstream/v0.3.0
Diffstat (limited to 'lib/CIL/Issue.pm')
-rw-r--r-- | lib/CIL/Issue.pm | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/lib/CIL/Issue.pm b/lib/CIL/Issue.pm index 0dfaf53..d44626e 100644 --- a/lib/CIL/Issue.pm +++ b/lib/CIL/Issue.pm @@ -90,6 +90,37 @@ sub last_field { return 'Description'; } +sub is_valid { + my ($self, $cil) = @_; + + my @errors; + + # issues should have a Summary + unless ( defined defined $self->Summary and length $self->Summary ) { + push @errors, 'Issue does not have a summary'; + } + + # see if we only allow certain Statuses + if ( $cil->StatusStrict ) { + unless ( exists $cil->StatusAllowed()->{$self->Status} ) { + push @errors, "StatusStrict is turned on but this issue has an invalid status '" . $self->Status . "'"; + } + } + + # see if we only allow certain Labels + if ( $cil->LabelStrict ) { + my @labels = @{$self->Labels}; + foreach my $label ( @labels ) { + unless ( exists $cil->LabelAllowed()->{$label} ) { + push @errors, "LabelStrict is turned on but this issue has an invalid label '$label'"; + } + } + } + + $self->errors( \@errors ); + return @errors ? 0 : 1; +} + sub add_label { my ($self, $label) = @_; @@ -124,9 +155,9 @@ sub add_attachment { $self->flag_as_updated(); } -sub as_output { +sub Labels { my ($self) = @_; - return CIL::Utils->format_data_as_output( $self->{data}, @FIELDS ); + return $self->{data}{Label}; } sub Comments { @@ -139,6 +170,34 @@ sub Attachments { return $self->{data}{Attachment}; } +sub is_open { + my ($self, $cil) = @_; + + # check against the list of Open Statuses + my $open = $cil->StatusOpen(); + return exists $open->{$self->Status}; +} + +sub is_closed { + my ($self, $cil) = @_; + + # check against the list of Closed Statuses + my $closed = $cil->StatusClosed(); + return exists $closed->{$self->Status}; +} + +sub assigned_to_email { + my ($self) = @_; + + return CIL::Utils->extract_email_address( $self->AssignedTo ); +} + +sub created_by_email { + my ($self) = @_; + + return CIL::Utils->extract_email_address( $self->CreatedBy ); +} + ## ---------------------------------------------------------------------------- 1; ## ---------------------------------------------------------------------------- |