Skip to content

Commit

Permalink
default status rework
Browse files Browse the repository at this point in the history
  • Loading branch information
noumo committed May 17, 2015
1 parent b33cbc7 commit 1c0cab6
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion components/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function rules()
['title', 'string', 'max' => 128],
['image', 'image'],
['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')],
['slug', 'default', 'value' => null]
['slug', 'default', 'value' => null],
['status', 'integer'],
['status', 'default', 'value' => self::STATUS_ON]
];
}

Expand Down
1 change: 0 additions & 1 deletion modules/article/controllers/ItemsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function actionCreate($id)
$model->image = '';
}
}
$model->status = Item::STATUS_ON;

if ($model->save()) {
$this->flash('success', Yii::t('easyii/article', 'Article created'));
Expand Down
3 changes: 2 additions & 1 deletion modules/article/models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public function rules()
[['title', 'short', 'text'], 'trim'],
['title', 'string', 'max' => 128],
['image', 'image'],
[['views', 'time'], 'integer'],
[['category_id', 'views', 'time', 'status'], 'integer'],
['time', 'default', 'value' => time()],
['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')],
['slug', 'default', 'value' => null],
['status', 'default', 'value' => self::STATUS_ON],
];
}

Expand Down
2 changes: 2 additions & 0 deletions modules/carousel/models/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function rules()
return [
['image', 'image'],
[['title', 'text', 'link'], 'trim'],
['status', 'integer'],
['status', 'default', 'value' => self::STATUS_ON],
];
}

Expand Down
2 changes: 0 additions & 2 deletions modules/catalog/controllers/ItemsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public function actionCreate($id)
$model->image = '';
}
}
$model->status = Item::STATUS_ON;

if ($model->save()) {
$this->flash('success', Yii::t('easyii/catalog', 'Item created'));
return $this->redirect(['/admin/'.$this->module->id.'/items/edit/', 'id' => $model->primaryKey]);
Expand Down
3 changes: 2 additions & 1 deletion modules/catalog/models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ public function rules()
['description', 'safe'],
['price', 'number'],
['discount', 'integer', 'max' => 99],
[['available', 'time'], 'integer'],
[['status', 'category_id', 'available', 'time'], 'integer'],
['time', 'default', 'value' => time()],
['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')],
['slug', 'default', 'value' => null],
['status', 'default', 'value' => self::STATUS_ON],
];
}

Expand Down
2 changes: 0 additions & 2 deletions modules/faq/controllers/AController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function actionCreate($slug = null)
return ActiveForm::validate($model);
}
else{
$model->status = Faq::STATUS_ON;

if($model->save()){
$this->flash('success', Yii::t('easyii/faq', 'Entry created'));
return $this->redirect(['/admin/'.$this->module->id]);
Expand Down
2 changes: 2 additions & 0 deletions modules/faq/models/Faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public function rules()
return [
[['question','answer'], 'required'],
[['question', 'answer'], 'trim'],
['status', 'integer'],
['status', 'default', 'value' => self::STATUS_ON],
];
}

Expand Down
2 changes: 0 additions & 2 deletions modules/news/controllers/AController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public function actionCreate()
$model->image = '';
}
}
$model->status = News::STATUS_ON;

if($model->save()){
$this->flash('success', Yii::t('easyii/news', 'News created'));
return $this->redirect(['/admin/'.$this->module->id]);
Expand Down
5 changes: 3 additions & 2 deletions modules/news/models/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ public function rules()
[['title', 'short', 'text'], 'trim'],
['title', 'string', 'max' => 128],
['image', 'image'],
[['views', 'time'], 'integer'],
[['views', 'time', 'status'], 'integer'],
['time', 'default', 'value' => time()],
['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')],
['slug', 'default', 'value' => null]
['slug', 'default', 'value' => null],
['status', 'default', 'value' => self::STATUS_ON],
];
}

Expand Down

0 comments on commit 1c0cab6

Please sign in to comment.