Merge pull request #5647 from coolacid/issue-5598

Allow forcing tag creation for galaxies
pull/5651/head
Andras Iklody 2020-02-19 09:27:45 +01:00 committed by GitHub
commit 42c16351f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -220,7 +220,7 @@ class Galaxy extends AppModel
throw new NotFoundException(__('Invalid %s.', $target_type));
}
$target = $target[0];
$tag_id = $this->Tag->captureTag(array('name' => $cluster['GalaxyCluster']['tag_name'], 'colour' => '#0088cc', 'exportable' => 1), $user);
$tag_id = $this->Tag->captureTag(array('name' => $cluster['GalaxyCluster']['tag_name'], 'colour' => '#0088cc', 'exportable' => 1), $user, true);
$existingTag = $this->Tag->$connectorModel->find('first', array('conditions' => array($target_type . '_id' => $target_id, 'tag_id' => $tag_id)));
if (!empty($existingTag)) {
return 'Cluster already attached.';

View File

@ -299,14 +299,14 @@ class Tag extends AppModel
return $ids;
}
public function captureTag($tag, $user)
public function captureTag($tag, $user, $force=false)
{
$existingTag = $this->find('first', array(
'recursive' => -1,
'conditions' => array('LOWER(name)' => strtolower($tag['name']))
));
if (empty($existingTag)) {
if ($user['Role']['perm_tag_editor']) {
if ($force || $user['Role']['perm_tag_editor']) {
$this->create();
if (!isset($tag['colour']) || empty($tag['colour'])) {
$tag['colour'] = $this->random_color();