-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Update dataset image on admin dataset form page
This is a merge pull request #978 from kencho51/Feature-964-update-image-in-update-form. Users can now update on the dataset admin pages at /adminDataset/update/id/<number>. Images are uploaded into S3. If a dataset has no image then the no_image.png is displayed. A new acceptance test checks the functionality of the new admin dataset form page.
- Loading branch information
Showing
13 changed files
with
379 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
protected/migrations/schema/m220309_165454_generic_image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
class m220309_165454_generic_image extends CDbMigration | ||
{ | ||
public function safeUp() | ||
{ | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN license SET DEFAULT 'All rights reserved'"); | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN photographer SET DEFAULT 'n/a'"); | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN source SET DEFAULT 'GigaDB'"); | ||
$this->insert("image", ['id' => 0, 'location' => 'no_image.png', 'url' =>'https://assets.gigadb-cdn.net/images/datasets/no_image.png']); | ||
} | ||
|
||
public function safeDown() | ||
{ | ||
$this->delete("image", ['id=0']); | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN license DROP DEFAULT"); | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN photographer DROP DEFAULT"); | ||
$this->execute("ALTER TABLE ONLY image ALTER COLUMN source DROP DEFAULT"); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/** | ||
* This is the model class for table "image". | ||
* Note: I have to change this Model to Images instead of Image because of this name is conflict with Image.php in the Extension | ||
* | ||
* The followings are the available columns in table 'image': | ||
* @property integer $id | ||
* @property string $tag | ||
* @property string $url | ||
* @property string $license | ||
* @property string $photographer | ||
* @property string $source | ||
* | ||
* The followings are the available model relations: | ||
* @property Dataset[] $datasets | ||
*/ | ||
class Image extends CActiveRecord | ||
{ | ||
/** | ||
* Returns the static model of the specified AR class. | ||
* @param string $className active record class name. | ||
* @return Image the static model class | ||
*/ | ||
public static function model($className=__CLASS__) | ||
{ | ||
return parent::model($className); | ||
} | ||
|
||
/** | ||
* @return string the associated database table name | ||
*/ | ||
public function tableName() | ||
{ | ||
return 'image'; | ||
} | ||
|
||
/** | ||
* @return array validation rules for model attributes. | ||
*/ | ||
public function rules() | ||
{ | ||
// NOTE: you should only define rules for those attributes that | ||
// will receive user inputs. | ||
return array( | ||
array('license, photographer, source', 'required'), | ||
array('tag', 'length', 'max'=>120), | ||
array('url, source', 'length', 'max'=>256), | ||
array('photographer', 'length', 'max'=>128), | ||
// The following rule is used by search(). | ||
// Please remove those attributes that should not be searched. | ||
array('id, tag, url, license, photographer, source', 'safe', 'on'=>'search'), | ||
); | ||
} | ||
|
||
/** | ||
* @return array relational rules. | ||
*/ | ||
public function relations() | ||
{ | ||
// NOTE: you may need to adjust the relation name and the related | ||
// class name for the relations automatically generated below. | ||
return array( | ||
'datasets' => array(self::HAS_MANY, 'Dataset', 'image_id'), | ||
); | ||
} | ||
|
||
/** | ||
* @return array customized attribute labels (name=>label) | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return array( | ||
'id' => 'ID', | ||
'tag' => 'Image Tag', | ||
'url' => 'Image URL', | ||
'license' => 'Image License', | ||
'photographer' => 'Image Photographer', | ||
'source' => 'Image Source', | ||
'image_upload' => 'Upload Image', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.