diff options
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; ## ---------------------------------------------------------------------------- |