Skip to content

Commit 091c282

Browse files
committed
[smarcet] - #13793
* updated summit model to allow to especify the default event(presentation) types that entity is global an allow to seed by summit the initial event(presentation)types
1 parent f544db8 commit 091c282

11 files changed

Lines changed: 415 additions & 147 deletions

File tree

migrations/migrations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ migrations:
100100
- AddSummitCalendarSyncErrorEmailMigration
101101
- RefactorDefaultEventTypesMigration
102102
- PopulateSubCategoriesAndTagsMigration
103+
- AddDefaultEventTypesPresentationTypesMigration

summit/code/admins/GridFieldAddDefaultEventTypes.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* Copyright 2015 OpenStack Foundation
54
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +11,11 @@
1211
* See the License for the specific language governing permissions and
1312
* limitations under the License.
1413
**/
15-
class GridFieldAddDefaultEventTypes implements GridField_HTMLProvider, GridField_URLHandler, GridField_ActionProvider {
14+
15+
/**
16+
* Class GridFieldAddDefaultEventTypes
17+
*/
18+
final class GridFieldAddDefaultEventTypes implements GridField_HTMLProvider, GridField_URLHandler, GridField_ActionProvider {
1619

1720
protected $targetFragment;
1821

@@ -29,7 +32,7 @@ public function getHTMLFragments($gridField) {
2932
$button = new GridField_FormAction(
3033
$gridField,
3134
'defaultEventTypes',
32-
'Add Default Event Types',
35+
'Seed Default Event Types',
3336
'addDefaultEventTypes',
3437
null
3538
);

summit/code/admins/SummitAdmin.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright 2018 OpenStack Foundation
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
**/
13+
(function($) {
14+
$.entwine('ss', function($){
15+
16+
});
17+
})(jQuery);

summit/code/admins/SummitAdmin.php

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
<?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+
**/
214

3-
class SummitAdmin extends ModelAdmin implements PermissionProvider
15+
/**
16+
* Class SummitAdmin
17+
*/
18+
final class SummitAdmin extends ModelAdmin implements PermissionProvider
419
{
520
private static $url_segment = 'summits';
621

722
public $showImportForm = false;
823

9-
private static $managed_models = array
10-
(
24+
private static $managed_models =
25+
[
1126
'Summit',
1227
'SummitType',
13-
);
28+
'DefaultSummitEventType' => ['title' => "Default Event Types"],
29+
];
1430

1531
public function init()
1632
{
1733
parent::init();
1834
Requirements::javascript('summit/javascript/GridFieldApprovePushNotificationAction.js');
35+
Requirements::javascript('summit/code/admins/SummitAdmin.js');
1936
$res = Permission::check("ADMIN") || Permission::check("ADMIN_SUMMIT_APP") || Permission::check("ADMIN_SUMMIT_APP_SCHEDULE");
2037
if (!$res) {
2138
Security::permissionFailure();
@@ -24,20 +41,52 @@ public function init()
2441

2542
private static $menu_title = 'Summits';
2643

44+
public function index($request) {
45+
if($request->getURL() == 'admin/summits'){
46+
return Controller::curr()->redirect("admin/summits/Summit");
47+
}
48+
return parent::index($request);
49+
}
50+
51+
2752
public function providePermissions() {
28-
return array(
29-
'ADMIN_SUMMIT_APP' => array(
53+
return [
54+
'ADMIN_SUMMIT_APP' => [
3055
'name' => 'Full Access to Summit CMS Admin',
3156
'category' => 'Summit Application',
3257
'help' => '',
3358
'sort' => 0
34-
),
35-
'ADMIN_SUMMIT_APP_SCHEDULE' => array(
59+
],
60+
'ADMIN_SUMMIT_APP_SCHEDULE' => [
3661
'name' => 'Full Access to Summit CMS Schedule Admin',
3762
'category' => 'Summit Application',
3863
'help' => '',
3964
'sort' => 1
40-
),
41-
);
65+
],
66+
];
67+
}
68+
69+
public function getEditForm($id = null, $fields = null) {
70+
71+
$form = parent:: getEditForm($id, $fields);
72+
73+
if($this->modelClass === 'DefaultSummitEventType') {
74+
$gridField = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
75+
$config = $gridField->getConfig();
76+
$config->removeComponentsByType('GridFieldAddNewButton');
77+
$config->removeComponentsByType('GridFieldExportButton');
78+
$config->removeComponentsByType('GridFieldPrintButton');
79+
$multi_class_selector = new GridFieldAddNewMultiClass();
80+
$multi_class_selector->setClasses
81+
(
82+
[
83+
'DefaultSummitEventType' => 'Default Event Type',
84+
'DefaultPresentationType' => 'Default Presentation Type',
85+
]
86+
);
87+
$config->addComponent($multi_class_selector);
88+
}
89+
90+
return $form;
4291
}
4392
}

summit/code/infrastructure/active_records/Summit.php

Lines changed: 9 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ public static function GetUpcoming()
484484
{
485485
$now = new \DateTime('now', new DateTimeZone('UTC'));
486486

487-
return Summit::get()->filter(array(
487+
return Summit::get()->filter([
488488
'SummitBeginDate:GreaterThanOrEqual' => $now->format('Y-m-d H:i:s'),
489489
'SummitEndDate:GreaterThanOrEqual' => $now->format('Y-m-d H:i:s'),
490490
'Active' => 1
491-
))->first();
491+
])->first();
492492
}
493493

494494
private $must_seed = false;
@@ -1056,133 +1056,14 @@ public function findTicketTypeByExternalId($ticket_external_id)
10561056
*/
10571057
public static function seedBasicEventTypes($summit_id)
10581058
{
1059-
$presentation = SummitEventType::get()->filter(['Type' => IPresentationType::Presentation, 'SummitID' => $summit_id])->first();
1060-
if (is_null($presentation)) {
1061-
$presentation = new PresentationType();
1062-
}
1063-
1064-
$presentation->Type = IPresentationType::Presentation;
1065-
$presentation->SummitID = $summit_id;
1066-
$presentation->MinSpeakers = 1;
1067-
$presentation->MaxSpeakers = 3;
1068-
$presentation->MinModerators = 0;
1069-
$presentation->MaxModerators = 0;
1070-
$presentation->UseSpeakers = true;
1071-
$presentation->ShouldBeAvailableOnCFP = true;
1072-
$presentation->AreSpeakersMandatory = false;
1073-
$presentation->UseModerator = false;
1074-
$presentation->IsModeratorMandatory = false;
1075-
$presentation->IsDefault = true;
1076-
$presentation->write();
1077-
1078-
$key_note = SummitEventType::get()->filter(['Type' => IPresentationType::Keynotes, 'SummitID' => $summit_id])->first();
1079-
if (is_null($key_note)) {
1080-
$key_note = new PresentationType();
1059+
foreach(DefaultSummitEventType::get() as $default_event_type){
1060+
if(SummitEventType::get()->filter([
1061+
'Type' => $default_event_type->Type,
1062+
'SummitID' => $summit_id
1063+
])->count() > 0 ) continue;
1064+
$event_type = $default_event_type->buildEventType($summit_id);
1065+
$event_type->write();
10811066
}
1082-
1083-
$key_note->Type = IPresentationType::Keynotes;
1084-
$key_note->SummitID = $summit_id;
1085-
$key_note->MinSpeakers = 1;
1086-
$key_note->MaxSpeakers = 3;
1087-
$key_note->MinModerators = 0;
1088-
$key_note->MaxModerators = 1;
1089-
$key_note->ShouldBeAvailableOnCFP = false;
1090-
$key_note->UseSpeakers = true;
1091-
$key_note->AreSpeakersMandatory = false;
1092-
$key_note->UseModerator = true;
1093-
$key_note->IsModeratorMandatory = false;
1094-
$key_note->IsDefault = true;
1095-
$key_note->write();
1096-
1097-
$panel = SummitEventType::get()->filter(['Type' => IPresentationType::Panel, 'SummitID' => $summit_id])->first();
1098-
if (is_null($panel)) {
1099-
$panel = new PresentationType();
1100-
}
1101-
1102-
$panel->Type = IPresentationType::Panel;
1103-
$panel->SummitID = $summit_id;
1104-
$panel->MinSpeakers = 1;
1105-
$panel->MaxSpeakers = 3;
1106-
$panel->MinModerators = 0;
1107-
$panel->MaxModerators = 1;
1108-
$panel->ShouldBeAvailableOnCFP = true;
1109-
$panel->UseSpeakers = true;
1110-
$panel->AreSpeakersMandatory = false;
1111-
$panel->UseModerator = true;
1112-
$panel->IsModeratorMandatory = false;
1113-
$panel->IsDefault = true;
1114-
$panel->write();
1115-
1116-
$lighting_talks = SummitEventType::get()->filter(['Type' => IPresentationType::LightingTalks, 'SummitID' => $summit_id])->first();
1117-
if (is_null($lighting_talks)) {
1118-
$lighting_talks = new PresentationType();
1119-
}
1120-
1121-
$lighting_talks->Type = IPresentationType::LightingTalks;
1122-
$lighting_talks->SummitID = $summit_id;
1123-
$lighting_talks->MinSpeakers = 1;
1124-
$lighting_talks->MaxSpeakers = 3;
1125-
$lighting_talks->MinModerators = 0;
1126-
$lighting_talks->MaxModerators = 0;
1127-
$lighting_talks->UseSpeakers = true;
1128-
$lighting_talks->ShouldBeAvailableOnCFP = true;
1129-
$lighting_talks->AreSpeakersMandatory = false;
1130-
$lighting_talks->UseModerator = false;
1131-
$lighting_talks->IsModeratorMandatory = false;
1132-
$lighting_talks->IsDefault = true;
1133-
$lighting_talks->write();
1134-
1135-
$hand_on_labs = SummitEventType::get()->filter(['Type' => ISummitEventType::HandonLabs, 'SummitID' => $summit_id])->first();
1136-
if (is_null($hand_on_labs)) {
1137-
$hand_on_labs = new SummitEventType();
1138-
1139-
}
1140-
1141-
$hand_on_labs->Type = ISummitEventType::HandonLabs;
1142-
$hand_on_labs->SummitID = $summit_id;
1143-
$hand_on_labs->IsDefault = true;
1144-
$hand_on_labs->write();
1145-
1146-
$lunch = SummitEventType::get()->filter(['Type' => ISummitEventType::Lunch, 'SummitID' => $summit_id])->first();
1147-
if (is_null($lunch)) {
1148-
$lunch = new SummitEventType();
1149-
}
1150-
1151-
$lunch->Type = ISummitEventType::Lunch;
1152-
$lunch->SummitID = $summit_id;
1153-
$lunch->IsDefault = true;
1154-
$lunch->write();
1155-
1156-
$breaks = SummitEventType::get()->filter(['Type' => ISummitEventType::Breaks, 'SummitID' => $summit_id])->first();
1157-
if (is_null($breaks)) {
1158-
$breaks = new SummitEventType();
1159-
}
1160-
1161-
$breaks->Type = ISummitEventType::Breaks;
1162-
$breaks->SummitID = $summit_id;
1163-
$breaks->IsDefault = true;
1164-
$breaks->write();
1165-
1166-
$evening_events = SummitEventType::get()->filter(['Type' => ISummitEventType::EveningEvents, 'SummitID' => $summit_id])->first();
1167-
if (is_null($evening_events)) {
1168-
$evening_events = new SummitEventType();
1169-
}
1170-
1171-
$evening_events->Type = ISummitEventType::EveningEvents;
1172-
$evening_events->SummitID = $summit_id;
1173-
$breaks->IsDefault = true;
1174-
$evening_events->write();
1175-
1176-
1177-
$groups_events = SummitEventType::get()->filter(['Type' => ISummitEventType::GroupsEvents, 'SummitID' => $summit_id])->first();
1178-
if (is_null($groups_events)) {
1179-
$groups_events = new SummitEventType();
1180-
}
1181-
1182-
$groups_events->Type = ISummitEventType::GroupsEvents;
1183-
$groups_events->SummitID = $summit_id;
1184-
$groups_events->IsDefault = true;
1185-
$groups_events->write();
11861067
}
11871068

11881069
/**
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 DefaultPresentationType
17+
*/
18+
final class DefaultPresentationType extends DefaultSummitEventType
19+
{
20+
private static $db = [
21+
22+
'MaxSpeakers' => 'Int',
23+
'MinSpeakers' => 'Int',
24+
'MaxModerators' => 'Int',
25+
'MinModerators' => 'Int',
26+
'UseSpeakers' => 'Boolean',
27+
'AreSpeakersMandatory' => 'Boolean',
28+
'UseModerator' => 'Boolean',
29+
'IsModeratorMandatory' => 'Boolean',
30+
'ModeratorLabel' => 'VarChar(255)',
31+
'ShouldBeAvailableOnCFP' => 'Boolean',
32+
];
33+
34+
public function getCMSFields() {
35+
$fields = parent::getCMSFields();
36+
$fields->removeByName('AllowsAttachment');
37+
38+
$fields->add(new CheckboxField("ShouldBeAvailableOnCFP","Should be available on CFP ?"));
39+
40+
$fields->add(new CheckboxField("UseSpeakers","Should use Speakers?"));
41+
$fields->add(new CheckboxField("AreSpeakersMandatory","Are Speakers Mandatory?"));
42+
$fields->add(new TextField("MinSpeakers","Min Speakers"));
43+
$fields->add(new TextField("MaxSpeakers","Max Speakers"));
44+
45+
$fields->add(new CheckboxField("UseModerator","Should use Moderator?"));
46+
$fields->add(new CheckboxField("IsModeratorMandatory","Is Moderator Mandatory?"));
47+
$fields->add(new TextField('ModeratorLabel', 'Moderator Label'));
48+
$fields->add(new TextField("MinModerators","Min Moderators"));
49+
$fields->add(new TextField("MaxModerators","Max Moderators"));
50+
51+
return $fields;
52+
}
53+
54+
/**
55+
* @return PresentationType
56+
*/
57+
protected function buildType(){
58+
return new PresentationType();
59+
}
60+
61+
/**
62+
* @param int $summit_id
63+
* @return SummitEventType
64+
*/
65+
public function buildEventType($summit_id){
66+
$event_type = parent::buildEventType($summit_id);
67+
$event_type->MaxSpeakers = $this->MaxSpeakers;
68+
$event_type->MinSpeakers = $this->MinSpeakers;
69+
$event_type->MaxModerators = $this->MaxModerators;
70+
$event_type->MinModerators = $this->MinModerators;
71+
$event_type->UseSpeakers = $this->UseSpeakers;
72+
$event_type->AreSpeakersMandatory = $this->AreSpeakersMandatory;
73+
$event_type->UseModerator = $this->UseModerator;
74+
$event_type->IsModeratorMandatory = $this->IsModeratorMandatory;
75+
$event_type->IsModeratorMandatory = $this->IsModeratorMandatory;
76+
$event_type->ModeratorLabel = $this->ModeratorLabel;
77+
$event_type->ShouldBeAvailableOnCFP = $this->ShouldBeAvailableOnCFP;
78+
79+
return $event_type;
80+
}
81+
82+
}

0 commit comments

Comments
 (0)