Skip to content

Commit fef58b5

Browse files
committed
[smarcet] - #13859
* CFP track tag group refactoring
1 parent 6f101a4 commit fef58b5

16 files changed

Lines changed: 559 additions & 217 deletions

migrations/migrations.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ migrations:
100100
- AddSummitCalendarSyncErrorEmailMigration
101101
- RefactorDefaultEventTypesMigration
102102
- PopulateSubCategoriesAndTagsMigration
103-
- AddDefaultEventTypesPresentationTypesMigration
103+
- AddDefaultEventTypesPresentationTypesMigration
104+
- CFPTrackTagGroupsRefactoringMigration

openstack/code/utils/DB/CustomMySQLDatabase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public function transactionEnd($chain = false){
9797

9898
public function query($sql, $errorLevel = E_USER_ERROR) {
9999
$query = parent::query($sql, $errorLevel);
100-
//SS_Log::log($sql, SS_Log::DEBUG);
100+
if(Director::isDev())
101+
SS_Log::log($sql, SS_Log::DEBUG);
101102
return $query;
102103
}
103104

summit/code/admins/GridFieldApprovePushNotificationAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
**/
15-
class GridFieldApprovePushNotificationAction implements GridField_ColumnProvider, GridField_ActionProvider
15+
class GridFieldApprovePushNotificationAction
16+
implements GridField_ColumnProvider, GridField_ActionProvider
1617
{
1718
public function augmentColumns($gridField, &$columns)
1819
{
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
* Copyright 2018 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
final class GridFieldSeedAllowedTagOnAllSummitTracksColumnAction
16+
implements GridField_ColumnProvider, GridField_ActionProvider
17+
{
18+
public function augmentColumns($gridField, &$columns)
19+
{
20+
if (!in_array('Actions', $columns)) {
21+
$columns[] = 'Actions';
22+
}
23+
}
24+
25+
public function getColumnAttributes($gridField, $record, $columnName)
26+
{
27+
return ['class' => 'col-buttons'];
28+
}
29+
30+
public function getColumnMetadata($gridField, $columnName)
31+
{
32+
if ($columnName == 'Actions') {
33+
return ['title' => ''];
34+
}
35+
}
36+
37+
public function getColumnsHandled($gridField)
38+
{
39+
return array('Actions');
40+
}
41+
42+
public function getColumnContent($gridField, $record, $columnName)
43+
{
44+
if (!$record->canEdit()) return;
45+
46+
$tag = $gridField->getList()->byID($record->ID);
47+
48+
$title = 'Seed Tag on All Tracks Allowed Tags';
49+
$icon = 'add' ;
50+
51+
$field = GridField_FormAction::create($gridField, 'seedallowedtagonallsummittracks' . $record->ID, false, "seedallowedtagonallsummittracks",
52+
['RecordID' => $record->ID])
53+
->setAttribute('title', $title)
54+
->setAttribute('data-icon', $icon)
55+
->setDescription($title);
56+
57+
return $field->Field();
58+
}
59+
60+
public function getActions($gridField)
61+
{
62+
return ['seedallowedtagonallsummittracks'];
63+
}
64+
65+
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
66+
{
67+
if ($actionName == 'seedallowedtagonallsummittracks') {
68+
69+
$tag = $gridField->getList()->byID($arguments['RecordID']);
70+
$summit_id = $_REQUEST['SummitID'];
71+
72+
Summit::seedTagOnAllTracksAllowedTags(
73+
Summit::get()->byID($summit_id),
74+
$tag
75+
);
76+
$code = 200;
77+
$msg = 'tag added sucessfull from all summit tracks';
78+
79+
try {
80+
81+
} catch (Exception $ex) {
82+
throw new ValidationException($ex->getMessage(), 0);
83+
}
84+
85+
Controller::curr()->getResponse()->setStatusCode($code, $msg);
86+
}
87+
}
88+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright 2018 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
/**
16+
* Class GridFieldSeedDefaultTrackTagGroupsAction
17+
*/
18+
final class GridFieldSeedDefaultTrackTagGroupsAction
19+
implements GridField_HTMLProvider, GridField_URLHandler, GridField_ActionProvider {
20+
21+
protected $targetFragment;
22+
23+
private static $allowed_actions = [
24+
'handleGridFieldSeedDefaultTrackTagGroupsAction'
25+
];
26+
27+
public function __construct($targetFragment = 'before') {
28+
$this->targetFragment = $targetFragment;
29+
}
30+
31+
//Generate the HTML fragment for the GridField
32+
public function getHTMLFragments($gridField) {
33+
$button = new GridField_FormAction(
34+
$gridField,
35+
'seedDefaultTrackTagGroupsAction',
36+
'Seed Default Track Tag Groups',
37+
'seedDefaultTrackTagGroupsAction',
38+
null
39+
);
40+
$button->setAttribute('data-icon', 'add');
41+
return [
42+
$this->targetFragment => $button->Field() ,
43+
];
44+
}
45+
/**
46+
* Return URLs to be handled by this grid field, in an array the same form
47+
* as $url_handlers.
48+
* Handler methods will be called on the component, rather than the
49+
* {@link GridField}.
50+
*/
51+
public function getURLHandlers($gridField)
52+
{
53+
return [
54+
'seedDefaultTrackTagGroupsAction' => 'handleSeedDefaultTrackTagGroupsAction'
55+
];
56+
}
57+
58+
public function handleSeedDefaultTrackTagGroupsAction($grid, $request, $data = null) {
59+
60+
$summit_id = intval($request->param('ID'));
61+
if($summit_id > 0 && $summit = Summit::get()->byID($summit_id))
62+
{
63+
Summit::seedDefaultTrackTagGroups($summit);
64+
}
65+
}
66+
67+
public function getActions($gridField) {
68+
return ['seedDefaultTrackTagGroupsAction'];
69+
}
70+
71+
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
72+
{
73+
if($actionName == 'seeddefaulttracktaggroupsaction') {
74+
return $this->handleSeedDefaultTrackTagGroupsAction($gridField,Controller::curr()->getRequest(), $data);
75+
}
76+
}
77+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Copyright 2018 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
class GridFieldUnSeedAllowedTagOnAllSummitTracksColumnAction
16+
implements GridField_ColumnProvider, GridField_ActionProvider
17+
{
18+
public function augmentColumns($gridField, &$columns)
19+
{
20+
if (!in_array('Actions', $columns)) {
21+
$columns[] = 'Actions';
22+
}
23+
}
24+
25+
public function getColumnAttributes($gridField, $record, $columnName)
26+
{
27+
return ['class' => 'col-buttons'];
28+
}
29+
30+
public function getColumnMetadata($gridField, $columnName)
31+
{
32+
if ($columnName == 'Actions') {
33+
return ['title' => ''];
34+
}
35+
}
36+
37+
public function getColumnsHandled($gridField)
38+
{
39+
return array('Actions');
40+
}
41+
42+
public function getColumnContent($gridField, $record, $columnName)
43+
{
44+
if (!$record->canEdit()) return;
45+
46+
$title = 'Remove Tag from All Tracks Allowed Tags';
47+
$icon = 'cross-circle' ;
48+
49+
$field = GridField_FormAction::create($gridField, 'unseedallowedtagonallsummittracks' . $record->ID, false, "unseedallowedtagonallsummittracks",
50+
['RecordID' => $record->ID])
51+
->setAttribute('title', $title)
52+
->setAttribute('data-icon', $icon)
53+
->setDescription($title);
54+
55+
return $field->Field();
56+
}
57+
58+
public function getActions($gridField)
59+
{
60+
return ['unseedallowedtagonallsummittracks'];
61+
}
62+
63+
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
64+
{
65+
if ($actionName == 'unseedallowedtagonallsummittracks') {
66+
67+
$tag = $gridField->getList()->byID($arguments['RecordID']);
68+
$summit_id = $_REQUEST['SummitID'];
69+
70+
Summit::unSeedTagOnAllTracksAllowedTags(
71+
Summit::get()->byID($summit_id),
72+
$tag
73+
);
74+
$code = 200;
75+
$msg = 'tag removed sucessfull from all summit tracks';
76+
77+
try {
78+
79+
} catch (Exception $ex) {
80+
throw new ValidationException($ex->getMessage(), 0);
81+
}
82+
83+
Controller::curr()->getResponse()->setStatusCode($code, $msg);
84+
}
85+
}
86+
}

summit/code/admins/GridFieldUpdateDefaultCategoryTags.php

Lines changed: 0 additions & 90 deletions
This file was deleted.

summit/code/admins/SummitAdmin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class SummitAdmin extends ModelAdmin implements PermissionProvider
2626
'Summit',
2727
'SummitType',
2828
'DefaultSummitEventType' => ['title' => "Default Event Types"],
29+
'DefaultTrackTagGroup' => ['title' => "Default Track Tag Groups"],
2930
];
3031

3132
public function init()

0 commit comments

Comments
 (0)