Skip to content
Permalink
Browse files

Fixed server order dedicated, changed ServerOrderDedicatedProduct::en…

…sureRelatedData(), fixed access control for `dedicated` action, fixed purchase params (#128)
  • Loading branch information...
tafid authored and hiqsol committed Jul 22, 2019
1 parent 01635f1 commit 0e3278cfe5d80741baf94805d2b2bb5bcbd40b1d
@@ -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');
}
@@ -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);
@@ -25,7 +25,7 @@ class ServerOrderDedicatedPurchase extends AbstractServerPurchase
/** {@inheritdoc} */
public static function operation()
{
return 'Buy';
return 'BuyConfig';
}
/** {@inheritdoc} */
@@ -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'],
]);
}
@@ -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
@@ -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'],
],
]
],
]);
}
@@ -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();

0 comments on commit 0e3278c

Please sign in to comment.
You can’t perform that action at this time.