diff --git a/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitValidationRulesFactory.php b/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitValidationRulesFactory.php index 056b6266..ca7bd989 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitValidationRulesFactory.php +++ b/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitValidationRulesFactory.php @@ -49,8 +49,25 @@ final class SummitValidationRulesFactory 'api_feed_type' => sprintf('nullable|in:%s',implode(',', Summit::$valid_feed_types)), 'api_feed_url' => 'nullable|string|url|required_with:api_feed_type', 'api_feed_key' => 'nullable|string|required_with:api_feed_type', - 'begin_allow_booking_date' => 'nullable|date_format:U', - 'end_allow_booking_date' => 'nullable|required_with:begin_allow_booking_date|date_format:U|after_or_equal:begin_allow_booking_date', + 'begin_allow_booking_date' => 'nullable|date_format:U', + 'end_allow_booking_date' => 'nullable|required_with:begin_allow_booking_date|date_format:U|after_or_equal:begin_allow_booking_date', + // schedule + 'schedule_default_page_url' => 'nullable|string', + 'schedule_default_event_detail_url' => 'nullable|string', + 'schedule_og_site_name' => 'nullable|string', + 'schedule_og_image_url' => 'nullable|string', + 'schedule_og_image_secure_url' => 'nullable|string', + 'schedule_og_image_width' => 'nullable|integer', + 'schedule_og_image_height' => 'nullable|integer', + 'schedule_facebook_app_id' => 'nullable|string', + 'schedule_ios_app_name' => 'nullable|string', + 'schedule_ios_app_store_id' => 'nullable|string', + 'schedule_ios_app_custom_schema' => 'nullable|string', + 'schedule_android_app_name' => 'nullable|string', + 'schedule_android_app_package' => 'nullable|string', + 'schedule_android_custom_schema' => 'nullable|string', + 'schedule_twitter_app_name' => 'nullable|string', + 'schedule_twitter_text' => 'nullable|string', ]; } @@ -84,6 +101,23 @@ final class SummitValidationRulesFactory 'api_feed_key' => 'nullable|string|required_with:api_feed_type', 'begin_allow_booking_date' => 'nullable|date_format:U', 'end_allow_booking_date' => 'nullable|required_with:begin_allow_booking_date|date_format:U|after_or_equal:begin_allow_booking_date', + // schedule + 'schedule_default_page_url' => 'nullable|string', + 'schedule_default_event_detail_url' => 'nullable|string', + 'schedule_og_site_name' => 'nullable|string', + 'schedule_og_image_url' => 'nullable|string', + 'schedule_og_image_secure_url' => 'nullable|string', + 'schedule_og_image_width' => 'nullable|integer', + 'schedule_og_image_height' => 'nullable|integer', + 'schedule_facebook_app_id' => 'nullable|string', + 'schedule_ios_app_name' => 'nullable|string', + 'schedule_ios_app_store_id' => 'nullable|string', + 'schedule_ios_app_custom_schema' => 'nullable|string', + 'schedule_android_app_name' => 'nullable|string', + 'schedule_android_app_package' => 'nullable|string', + 'schedule_android_custom_schema' => 'nullable|string', + 'schedule_twitter_app_name' => 'nullable|string', + 'schedule_twitter_text' => 'nullable|string', ]; } } \ No newline at end of file diff --git a/app/ModelSerializers/Summit/SummitSerializer.php b/app/ModelSerializers/Summit/SummitSerializer.php index b28bff74..3516bf36 100644 --- a/app/ModelSerializers/Summit/SummitSerializer.php +++ b/app/ModelSerializers/Summit/SummitSerializer.php @@ -59,7 +59,24 @@ class SummitSerializer extends SilverStripeSerializer 'MeetingRoomBookingMaxAllowed' => 'meeting_room_booking_max_allowed:json_int', 'BeginAllowBookingDate' => 'begin_allow_booking_date:datetime_epoch', 'EndAllowBookingDate' => 'end_allow_booking_date:datetime_epoch', - 'LogoUrl' => 'logo:json_url' + 'LogoUrl' => 'logo:json_url', + // schedule app + 'ScheduleDefaultPageUrl' => 'schedule_default_page_url:json_url', + 'ScheduleDefaultEventDetailUrl' => 'schedule_default_event_detail_url:json_url', + 'ScheduleOgSiteName' => 'schedule_og_site_name:json_string', + 'ScheduleOgImageUrl' => 'schedule_og_image_url:json_string', + 'ScheduleOgImageSecureUrl' => 'schedule_og_image_secure_url:json_string', + 'ScheduleOgImageWidth' => 'schedule_og_image_width:json_int', + 'ScheduleOgImageHeight' => 'schedule_og_image_height:json_int', + 'ScheduleFacebookAppId' => 'schedule_facebook_app_id:json_string', + 'ScheduleIosAppName' => 'schedule_ios_app_name:json_string', + 'ScheduleIosAppStoreId' => 'schedule_ios_app_store_id:json_string', + 'ScheduleIosAppCustomSchema' => 'schedule_ios_app_custom_schema:json_string', + 'ScheduleAndroidAppName' => 'schedule_android_app_name:json_string', + 'ScheduleAndroidAppPackage' => 'schedule_android_app_package:json_string', + 'ScheduleAndroidCustomSchema' => 'schedule_android_custom_schema:json_string', + 'ScheduleTwitterAppName' => 'schedule_twitter_app_name:json_string', + 'ScheduleTwitterText' => 'schedule_twitter_text:json_string', ]; protected static $allowed_relations = [ diff --git a/app/Models/Foundation/Summit/Factories/SummitFactory.php b/app/Models/Foundation/Summit/Factories/SummitFactory.php index 9666c18d..42c7fea5 100644 --- a/app/Models/Foundation/Summit/Factories/SummitFactory.php +++ b/app/Models/Foundation/Summit/Factories/SummitFactory.php @@ -204,6 +204,72 @@ final class SummitFactory $summit->setApiFeedKey(trim($data['api_feed_key'])); } + // schedule + + if(isset($data['schedule_default_page_url'])){ + $summit->setScheduleDefaultPageUrl(trim($data['schedule_default_page_url'])); + } + + if(isset($data['schedule_default_event_detail_url'])){ + $summit->setScheduleDefaultEventDetailUrl(trim($data['schedule_default_event_detail_url'])); + } + + if(isset($data['schedule_og_site_name'])){ + $summit->setScheduleOgSiteName(trim($data['schedule_og_site_name'])); + } + + if(isset($data['schedule_og_image_url'])){ + $summit->setScheduleOgImageUrl(trim($data['schedule_og_image_url'])); + } + + if(isset($data['schedule_og_image_secure_url'])){ + $summit->setScheduleOgImageSecureUrl(trim($data['schedule_og_image_secure_url'])); + } + + if(isset($data['schedule_og_image_width'])){ + $summit->setScheduleOgImageWidth(intval($data['schedule_og_image_width'])); + } + + if(isset($data['schedule_og_image_height'])){ + $summit->setScheduleOgImageHeight(intval($data['schedule_og_image_height'])); + } + + if(isset($data['schedule_facebook_app_id'])){ + $summit->setScheduleFacebookAppId(trim($data['schedule_facebook_app_id'])); + } + + if(isset($data['schedule_ios_app_name'])){ + $summit->setScheduleIosAppName(trim($data['schedule_ios_app_name'])); + } + + if(isset($data['schedule_ios_app_store_id'])){ + $summit->setScheduleIosAppStoreId(trim($data['schedule_ios_app_store_id'])); + } + + if(isset($data['schedule_ios_app_custom_schema'])){ + $summit->setScheduleIosAppCustomSchema(trim($data['schedule_ios_app_custom_schema'])); + } + + if(isset($data['schedule_android_app_name'])){ + $summit->setScheduleAndroidAppName(trim($data['schedule_android_app_name'])); + } + + if(isset($data['schedule_android_app_package'])){ + $summit->setScheduleAndroidAppPackage(trim($data['schedule_android_app_package'])); + } + + if(isset($data['schedule_android_custom_schema'])){ + $summit->setScheduleAndroidCustomSchema(trim($data['schedule_android_custom_schema'])); + } + + if(isset($data['schedule_twitter_app_name'])){ + $summit->setScheduleTwitterAppName(trim($data['schedule_twitter_app_name'])); + } + + if(isset($data['schedule_twitter_text'])){ + $summit->setScheduleTwitterText(trim($data['schedule_twitter_text'])); + } + return $summit; } } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Summit.php b/app/Models/Foundation/Summit/Summit.php index 62aa1450..b14548b8 100644 --- a/app/Models/Foundation/Summit/Summit.php +++ b/app/Models/Foundation/Summit/Summit.php @@ -18,6 +18,7 @@ use App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate; use App\Models\Foundation\Summit\SelectionPlan; use App\Models\Foundation\Summit\TrackTagGroup; use App\Models\Foundation\Summit\TrackTagGroupAllowedTag; +use App\Models\Utils\GetDefaultValueFromConfig; use App\Models\Utils\TimeZoneEntity; use App\Services\Apis\ExternalScheduleFeeds\IExternalScheduleFeedFactory; use Cocur\Slugify\Slugify; @@ -41,6 +42,9 @@ class Summit extends SilverstripeBaseModel { use TimeZoneEntity; + + use GetDefaultValueFromConfig; + /** * @ORM\Column(name="Title", type="string") * @var string @@ -272,6 +276,104 @@ class Summit extends SilverstripeBaseModel */ private $api_feed_key; + // schedule app + + /** + * @ORM\Column(name="ScheduleDefaultPageUrl", type="string", nullable=true) + * @var string + */ + private $schedule_default_page_url; + + /** + * @ORM\Column(name="ScheduleDefaultEventDetailUrl", type="string", nullable=true) + * @var string + */ + private $schedule_default_event_detail_url; + + /** + * @ORM\Column(name="ScheduleOGSiteName", type="string", nullable=true) + * @var string + */ + private $schedule_og_site_name; + + /** + * @ORM\Column(name="ScheduleOGImageUrl", type="string", nullable=true) + * @var string + */ + private $schedule_og_image_url; + + /** + * @ORM\Column(name="ScheduleOGImageSecureUrl", type="string", nullable=true) + * @var string + */ + private $schedule_og_image_secure_url; + + /** + * @ORM\Column(name="ScheduleOGImageWidth", type="integer", nullable=true) + * @var int + */ + private $schedule_og_image_width; + + /** + * @ORM\Column(name="ScheduleOGImageHeight", type="integer", nullable=true) + * @var int + */ + private $schedule_og_image_height; + + /** + * @ORM\Column(name="ScheduleFacebookAppId", type="string", nullable=true) + * @var string + */ + private $schedule_facebook_app_id; + + /** + * @ORM\Column(name="ScheduleIOSAppName", type="string", nullable=true) + * @var string + */ + private $schedule_ios_app_name; + + /** + * @ORM\Column(name="ScheduleIOSAppStoreId", type="string", nullable=true) + * @var string + */ + private $schedule_ios_app_store_id; + + /** + * @ORM\Column(name="ScheduleIOSAppCustomSchema", type="string", nullable=true) + * @var string + */ + private $schedule_ios_app_custom_schema; + + /** + * @ORM\Column(name="ScheduleAndroidAppName", type="string", nullable=true) + * @var string + */ + private $schedule_android_app_name; + + /** + * @ORM\Column(name="ScheduleAndroidAppPackage", type="string", nullable=true) + * @var string + */ + private $schedule_android_app_package; + + /** + * @ORM\Column(name="ScheduleAndroidAppCustomSchema", type="string", nullable=true) + * @var string + */ + private $schedule_android_custom_schema; + + /** + * @ORM\Column(name="ScheduleTwitterAppName", type="string", nullable=true) + * @var string + */ + private $schedule_twitter_app_name; + + /** + * @ORM\Column(name="ScheduleTwitterText", type="string", nullable=true) + * @var string + */ + private $schedule_twitter_text; + /** * @ORM\OneToMany(targetEntity="models\summit\SummitEventType", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY") */ @@ -2820,4 +2922,263 @@ SQL; } return $logoUrl; } + + // schedule + + /** + * @return string + */ + public function getScheduleDefaultPageUrl(): ?string + { + return $this->schedule_default_page_url; + } + + /** + * @param string $schedule_default_page_url + */ + public function setScheduleDefaultPageUrl(string $schedule_default_page_url): void + { + $this->schedule_default_page_url = $schedule_default_page_url; + } + + /** + * @return string + */ + public function getScheduleDefaultEventDetailUrl(): ?string + { + return $this->schedule_default_event_detail_url; + } + + /** + * @param string $schedule_default_event_detail_url + */ + public function setScheduleDefaultEventDetailUrl(string $schedule_default_event_detail_url): void + { + $this->schedule_default_event_detail_url = $schedule_default_event_detail_url; + } + + /** + * @return string + */ + public function getScheduleOgSiteName(): ?string + { + return self::_get($this->schedule_og_site_name, "schedule.og_site_name"); + } + + /** + * @param string $schedule_og_site_name + */ + public function setScheduleOgSiteName(string $schedule_og_site_name): void + { + $this->schedule_og_site_name = $schedule_og_site_name; + } + + /** + * @return string + */ + public function getScheduleOgImageUrl(): ?string + { + return self::_get($this->schedule_og_image_url,"schedule.og_image_url"); + } + + /** + * @param string $schedule_og_image_url + */ + public function setScheduleOgImageUrl(string $schedule_og_image_url): void + { + $this->schedule_og_image_url = $schedule_og_image_url; + } + + /** + * @return string + */ + public function getScheduleOgImageSecureUrl(): ?string + { + return self::_get($this->schedule_og_image_secure_url,"schedule.og_image_secure_url"); + } + + /** + * @param string $schedule_og_image_secure_url + */ + public function setScheduleOgImageSecureUrl(string $schedule_og_image_secure_url): void + { + $this->schedule_og_image_secure_url = $schedule_og_image_secure_url; + } + + /** + * @return int + */ + public function getScheduleOgImageWidth(): int + { + return self::_get($this->schedule_og_image_width,"schedule.og_image_width"); + } + + /** + * @param int $schedule_og_image_width + */ + public function setScheduleOgImageWidth(int $schedule_og_image_width): void + { + $this->schedule_og_image_width = $schedule_og_image_width; + } + + /** + * @return int + */ + public function getScheduleOgImageHeight(): int + { + return self::_get($this->schedule_og_image_height,"schedule.og_image_height"); + } + + /** + * @param int $schedule_og_image_height + */ + public function setScheduleOgImageHeight(int $schedule_og_image_height): void + { + $this->schedule_og_image_height = $schedule_og_image_height; + } + + /** + * @return string + */ + public function getScheduleFacebookAppId(): ?string + { + return self::_get($this->schedule_facebook_app_id,"schedule.facebook_app_id"); + } + + /** + * @param string $schedule_facebook_app_id + */ + public function setScheduleFacebookAppId(string $schedule_facebook_app_id): void + { + $this->schedule_facebook_app_id = $schedule_facebook_app_id; + } + + /** + * @return string + */ + public function getScheduleIosAppName(): ?string + { + return self::_get($this->schedule_ios_app_name,"schedule.ios_app_name"); + } + + /** + * @param string $schedule_ios_app_name + */ + public function setScheduleIosAppName(string $schedule_ios_app_name): void + { + $this->schedule_ios_app_name = $schedule_ios_app_name; + } + + /** + * @return string + */ + public function getScheduleIosAppStoreId(): ?string + { + return self::_get($this->schedule_ios_app_store_id,"schedule.ios_app_store_id"); + } + + /** + * @param string $schedule_ios_app_store_id + */ + public function setScheduleIosAppStoreId(string $schedule_ios_app_store_id): void + { + $this->schedule_ios_app_store_id = $schedule_ios_app_store_id; + } + + /** + * @return string + */ + public function getScheduleIosAppCustomSchema(): ?string + { + return self::_get($this->schedule_ios_app_custom_schema,"schedule.ios_app_custom_schema"); + } + + /** + * @param string $schedule_ios_app_custom_schema + */ + public function setScheduleIosAppCustomSchema(string $schedule_ios_app_custom_schema): void + { + $this->schedule_ios_app_custom_schema = $schedule_ios_app_custom_schema; + } + + /** + * @return string + */ + public function getScheduleAndroidAppName(): ?string + { + return self::_get($this->schedule_android_app_name,"schedule.android_app_name"); + } + + /** + * @param string $schedule_android_app_name + */ + public function setScheduleAndroidAppName(string $schedule_android_app_name): void + { + $this->schedule_android_app_name = $schedule_android_app_name; + } + + /** + * @return string + */ + public function getScheduleAndroidAppPackage(): ?string + { + return self::_get($this->schedule_android_app_package,"schedule.android_app_package"); + } + + /** + * @param string $schedule_android_app_package + */ + public function setScheduleAndroidAppPackage(string $schedule_android_app_package): void + { + $this->schedule_android_app_package = $schedule_android_app_package; + } + + /** + * @return string + */ + public function getScheduleAndroidCustomSchema(): ?string + { + return self::_get($this->schedule_android_custom_schema,"schedule.android_custom_schema"); + } + + /** + * @param string $schedule_android_custom_schema + */ + public function setScheduleAndroidCustomSchema(string $schedule_android_custom_schema): void + { + $this->schedule_android_custom_schema = $schedule_android_custom_schema; + } + + /** + * @return string + */ + public function getScheduleTwitterAppName(): ?string + { + return self::_get($this->schedule_twitter_app_name,"schedule.twitter_app_name"); + } + + /** + * @param string $schedule_twitter_app_name + */ + public function setScheduleTwitterAppName(string $schedule_twitter_app_name): void + { + $this->schedule_twitter_app_name = $schedule_twitter_app_name; + } + + /** + * @return string + */ + public function getScheduleTwitterText(): ?string + { + return self::_get($this->schedule_twitter_text,"schedule.twitter_text"); + } + + /** + * @param string $schedule_twitter_text + */ + public function setScheduleTwitterText(string $schedule_twitter_text): void + { + $this->schedule_twitter_text = $schedule_twitter_text; + } + } diff --git a/app/Models/Utils/GetDefaultValueFromConfig.php b/app/Models/Utils/GetDefaultValueFromConfig.php new file mode 100644 index 00000000..ad7c7d93 --- /dev/null +++ b/app/Models/Utils/GetDefaultValueFromConfig.php @@ -0,0 +1,32 @@ + env('SCHEDULE_OG_SITE_NAME', 'OpenStack'), + 'og_image_url' => env('SCHEDULE_OG_IMAGE_URL', 'https://object-storage-ca-ymq-1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-prod/Uploads/newsummitlogo.png'), + 'og_image_secure_url' => env('SCHEDULE_OG_IMAGE_SECURE_URL', 'https://object-storage-ca-ymq-1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-prod/Uploads/newsummitlogo.png'), + 'og_image_width' => env('SCHEDULE_OG_IMAGE_WIDTH', '240'), + 'og_image_height' => env('SCHEDULE_OG_IMAGE_HEIGHT', '135'), + 'facebook_app_id' => env('SCHEDULE_FACEBOOK_APP_ID', '209869746011654'), + 'ios_app_name' => env('SCHEDULE_IOS_APP_NAME', 'OpenStack Summit'), + 'ios_app_store_id' => env('SCHEDULE_IOS_APP_STORE_ID', '1071261846'), + 'ios_app_custom_schema' => env('SCHEDULE_IOS_APP_CUSTOM_SCHEMA', 'org.openstack.ios.summit'), + 'android_app_name' => env('SCHEDULE_ANDROID_APP_NAME', 'OpenStackSummitApplication'), + 'android_app_package' => env('SCHEDULE_ANDROID_APP_PACKAGE', 'org.openstack.android.summit'), + 'android_custom_schema' => env('SCHEDULE_ANDROID_CUSTOM_SCHEMA', 'org.openstack.android.summit'), + 'twitter_app_name' => env('SCHEDULE_TWITTER_APP_NAME', '@openstack'), + 'twitter_text' => env('SCHEDULE_TWITTER_TEXT', 'Check out this %23OpenStack session I\'m attending at the %23OpenStackSummit!'), +]; \ No newline at end of file diff --git a/database/migrations/model/Version20200213131907.php b/database/migrations/model/Version20200213131907.php new file mode 100644 index 00000000..7103d7d5 --- /dev/null +++ b/database/migrations/model/Version20200213131907.php @@ -0,0 +1,89 @@ +hasTable("Summit") && !$builder->hasColumn("Summit", "ScheduleEventDetailUrl")) { + $builder->table('Summit', function (Table $table) { + $table->text("ScheduleDefaultPageUrl")->setNotnull(false); + $table->text("ScheduleDefaultEventDetailUrl")->setNotnull(false); + // og tags + $table->text("ScheduleOGSiteName")->setNotnull(false); + $table->text("ScheduleOGImageUrl")->setNotnull(false); + $table->text("ScheduleOGImageSecureUrl")->setNotnull(false); + $table->integer("ScheduleOGImageWidth")->setNotnull(true)->setDefault(0); + $table->integer("ScheduleOGImageHeight")->setNotnull(true)->setDefault(0); + // face book app + $table->text("ScheduleFacebookAppId")->setNotnull(false); + // ios app + $table->text("ScheduleIOSAppName")->setNotnull(false); + $table->text("ScheduleIOSAppStoreId")->setNotnull(false); + $table->text("ScheduleIOSAppCustomSchema")->setNotnull(false); + // android app + $table->text("ScheduleAndroidAppName")->setNotnull(false); + $table->text("ScheduleAndroidAppPackage")->setNotnull(false); + $table->text("ScheduleAndroidAppCustomSchema")->setNotnull(false); + // twitter app + $table->text("ScheduleTwitterAppName")->setNotnull(false); + $table->text("ScheduleTwitterText")->setNotnull(false); + }); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $builder = new Builder($schema); + if($schema->hasTable("Summit") && $builder->hasColumn("Summit", "ScheduleEventDetailUrl")) { + $builder->table('Summit', function (Table $table) { + $table->dropColumn("ScheduleDefaultPageUrl"); + $table->dropColumn("ScheduleDefaultEventDetailUrl"); + // og tags + $table->dropColumn("ScheduleOGSiteName"); + $table->dropColumn("ScheduleOGImageUrl"); + $table->dropColumn("ScheduleOGImageSecureUrl"); + $table->dropColumn("ScheduleOGImageWidth"); + $table->dropColumn("ScheduleOGImageHeight"); + // face book app + $table->dropColumn("ScheduleFacebookAppId"); + // ios app + $table->dropColumn("ScheduleIOSAppName"); + $table->dropColumn("ScheduleIOSAppStoreId"); + $table->dropColumn("ScheduleIOSAppCustomSchema"); + // android app + $table->dropColumn("ScheduleAndroidAppName"); + $table->dropColumn("ScheduleAndroidAppPackage"); + $table->dropColumn("ScheduleAndroidAppCustomSchema"); + // twitter app + $table->dropColumn("ScheduleTwitterAppName"); + $table->dropColumn("ScheduleTwitterText"); + }); + } + } +} diff --git a/tests/BrowserKitTestCase.php b/tests/BrowserKitTestCase.php index 5fe413bf..31cfdebb 100644 --- a/tests/BrowserKitTestCase.php +++ b/tests/BrowserKitTestCase.php @@ -47,7 +47,8 @@ abstract class BrowserKitTestCase extends BaseTestCase */ protected function prepareForTests() { - Artisan::call('migrate'); + Artisan::call('doctrine:migrations:migrate', ["--connection" => 'config']); + Artisan::call('doctrine:migrations:migrate', ["--connection" => 'model']); //Mail::pretend(true); $this->seed('TestSeeder'); }