Permalink
Browse files

Prevent ordering captions if an order is already being processed

  • Loading branch information...
mfairchild365 committed Apr 28, 2016
1 parent d6a4d62 commit 2ccaa0d97aa1afb358a71721549c58d80655e514
@@ -39,4 +39,20 @@ public function getEditCaptionsURL()
return $amara_api->getCaptionEditURL($this->media->url);
}
/**
* Determine if any orders are currently pending
*
* @return bool
*/
public function hasPendingOrder()
{
foreach ($this->getRevOrderHistory()->items as $order) {
if ($order->isPending()) {
return true;
}
}
return false;
}
}
@@ -59,4 +59,31 @@ public function isSuccess()
return false;
}
/**
* Determine if this order is finished (success, cancel or error)
*/
public function isFinished()
{
$completed_statuses = array(
self::STATUS_CANCELLED,
self::STATUS_ERROR,
self::STATUS_MEDIAHUB_COMPLETE
);
if (in_array($this->status, $completed_statuses)) {
return true;
}
}
/**
* Determine if this media is still pending completion
*
* @return bool
*/
public function isPending()
{
return !$this->isFinished();
}
}
@@ -38,7 +38,8 @@
</div>
</div>
<div class="bp2-wdn-col-one-third">
<div class="mh-caption-sidebar">
<div class="mh-caption-sidebar">
<?php if (!$context->hasPendingOrder()): ?>
<form method="post">
<?php if ($duration = $context->media->findDuration()): ?>
<?php $estimate = ceil($duration['seconds']/60); ?>
@@ -63,6 +64,9 @@
<input type="submit" value="Order captions">
<p class="wdn-icon wdn-icon-attention wdn-sans-serif">Orders can not be canceled.</p>
</form>
<?php else: ?>
<p>Great news! There is an order already in the works.</p>
<?php endif; ?>
</div>

</div>

0 comments on commit 2ccaa0d

Please sign in to comment.