MT#9263 Fix CF API handling of timesets.

changes/94/294/1
Andreas Granig 11 years ago
parent 86fffe08e1
commit 3d22196c4a

@ -166,12 +166,13 @@ sub POST :Allow {
c => $c,
resource => $resource,
form => $form,
exceptions => [ "subscriber_id" ],
);
my $tset;
unless(defined $resource->{subscriber_id}) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Required: 'subscriber_id'");
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Missing mandatory field 'subscriber_id'");
last;
}
my $b_subscriber = $schema->resultset('voip_subscribers')->find({

@ -7,7 +7,8 @@ has 'max_end' => (isa => 'Int', default => 999_999, is => 'rw');
sub validate {
my ( $self ) = @_;
my ($start, $end) = $self->value =~ m/(\d+)-(\d+)/;
my ($start, $end) = split(/\-/, $self->value);
$end //= $start;
unless ((defined $start) && (defined $end) && $start >= 0 && $end >= 0) {
$self->add_error('Invalid format');
return;

@ -10,18 +10,23 @@ has_field 'name' => (
required => 1,
);
has_field 'subscriber' => ( # Workaround for validate_form
type => 'Compound',
);
has_field 'subscriber.id' => (
has_field 'subscriber_id' => (
type => 'PosInteger',
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The subscriber id this time set belongs to.']
},
);
has_field 'times' => (
type => 'Repeatable',
do_wrapper => 1,
do_label => 0,
element_attr => {
rel => ['tooltip'],
title => ['An array of time definitions with keys "year", "month", "mday", "wday", "hour", "minute", where each key can be a number like "10" or a range like "10-20".']
},
);
has_field 'times.id' => (

@ -59,6 +59,7 @@ sub hal_from_item {
form => $form,
resource => \%resource,
run => 0,
exceptions => [ "subscriber_id" ],
);
$hal->resource(\%resource);
return $hal;
@ -93,6 +94,7 @@ sub update_item {
c => $c,
form => $form,
resource => $resource,
exceptions => [ "subscriber_id" ],
);
if (! exists $resource->{times} ) {

Loading…
Cancel
Save