Skip to content

Commit

Permalink
Merge 478c7a9 into 01635f1
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Jul 22, 2019
2 parents 01635f1 + 478c7a9 commit 07ae65b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/cart/ServerOrderDedicatedProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function load($data, $formName = null)
/** {@inheritdoc} */
protected function ensureRelatedData()
{
$config = Config::find()->where(['id' => $this->object_id])->one();
$config = Config::find(['batch' => true])->getAvailable()->withSellerOptions()->andWhere(['id' => $this->object_id])->one();
if (empty($config)) {
throw new InvalidConfigException('Failed to find config');
}
Expand Down Expand Up @@ -126,12 +126,13 @@ public function getPurchaseModel($options = [])
$this->ensureRelatedData();

$options = array_merge([
'osimage' => $this->osimage,
'object_id' => $this->object_id,
'image' => $this->osimage,
'config_id' => $this->object_id,
'label' => $this->label,
'administration' => $this->administration,
'softpack' => $this->softpack,
'tariff_id' => $this->tariff_id,
'location' => $this->location,
], $options);

return parent::getPurchaseModel($options);
Expand Down
6 changes: 3 additions & 3 deletions src/cart/ServerOrderDedicatedPurchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ServerOrderDedicatedPurchase extends AbstractServerPurchase
/** {@inheritdoc} */
public static function operation()
{
return 'Buy';
return 'BuyConfig';
}

/** {@inheritdoc} */
Expand All @@ -39,8 +39,8 @@ public function init()
public function rules()
{
return array_merge(parent::rules(), [
[['osimage', 'config_id', 'tariff_id'], 'required'],
[['osimage', 'administration', 'softpack', 'label', 'location'], 'string'],
[['image', 'config_id', 'tariff_id'], 'required'],
[['image', 'administration', 'softpack', 'label', 'location'], 'string'],
[['tariff_id', 'object_id'], 'integer'],
]);
}
Expand Down
25 changes: 14 additions & 11 deletions src/controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
namespace hipanel\modules\server\controllers;

use hipanel\base\CrudController;
use hipanel\filters\EasyAccessControl;
use hipanel\modules\server\cart\ServerOrderDedicatedProduct;
use hipanel\modules\server\cart\ServerOrderProduct;
use hipanel\modules\server\models\Config;
use hipanel\modules\server\models\Osimage;
use hipanel\modules\server\Module;
use hiqdev\yii2\cart\actions\AddToCartAction;
use Yii;
use yii\filters\AccessControl;
use yii\web\ForbiddenHttpException;

class OrderController extends CrudController
Expand All @@ -44,16 +44,18 @@ public function behaviors()
{
return array_merge(parent::behaviors(), [
[
'class' => EasyAccessControl::class,
'actions' => [
'add-to-cart' => 'server.pay',
'add-to-cart-dedicated' => 'server.pay',
'index' => 'server.pay',
'xen-ssd' => 'server.pay',
'open-vz' => 'server.pay',
'dedicated' => '?',
'*' => 'server.read',
],
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'actions' => ['dedicated'],
],
[
'allow' => true,
'actions' => ['add-to-cart', 'add-to-cart-dedicated', 'index', 'xen-ssd', 'open-vz'],
'roles' => ['server.pay'],
],
]
],
]);
}
Expand Down Expand Up @@ -131,6 +133,7 @@ public function actionOpenVz()

public function actionDedicated()
{
Yii::$app->get('hiart')->disableAuth();
$this->layout = '@hipanel/server/order/yii/views/layouts/advancedhosting';
$configs = Config::find()->getAvailable()->withSellerOptions()->withPrices()->addOption('batch', true)->createCommand()->send()->getData();
$osimages = Osimage::find()->where(['type' => 'dedicated'])->all();
Expand Down

0 comments on commit 07ae65b

Please sign in to comment.