From 0f9d12f8a7aa2a5d36feea678de767094adb3ea1 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Fri, 9 Aug 2013 16:01:30 +0200 Subject: [PATCH] Prevent termination of contract with id 1. --- lib/NGCP/Panel/Controller/Contract.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Panel/Controller/Contract.pm b/lib/NGCP/Panel/Controller/Contract.pm index 246ce84224..2b91c8e536 100644 --- a/lib/NGCP/Panel/Controller/Contract.pm +++ b/lib/NGCP/Panel/Controller/Contract.pm @@ -234,9 +234,14 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) { sub terminate :Chained('base') :PathPart('terminate') :Args(0) { my ($self, $c) = @_; + my $contract = $c->stash->{contract_result}; + + if ($contract->id == 1) { + $c->flash(messages => [{type => 'error', text => 'Cannot terminate contract with the id 1'}]); + NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/contract')); + } try { - my $contract = $c->stash->{contract_result}; my $old_status = $contract->status; $contract->update({ status => 'terminated' }); # if status changed, populate it down the chain