Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static function buildForAdd(array $payload = []): array
'badge_image_alt_text' => 'sometimes|nullable|string|max:255',
'should_display_on_expo_hall_page' => 'sometimes|boolean',
'should_display_on_lobby_page' => 'sometimes|boolean',
'is_public' => 'sometimes|boolean',
];
}

Expand All @@ -65,6 +66,7 @@ public static function buildForUpdate(array $payload = []): array
'badge_image_alt_text' => 'sometimes|nullable|string|max:255',
'should_display_on_expo_hall_page' => 'sometimes|boolean',
'should_display_on_lobby_page' => 'sometimes|boolean',
'is_public' => 'sometimes|boolean',
];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Models\Foundation\Main\IGroup;
use App\Models\Foundation\Summit\Repositories\ISummitSponsorshipTypeRepository;
use App\ModelSerializers\SerializerUtils;
use App\Rules\Boolean;
use App\Security\SummitScopes;
use App\Services\Model\ISummitSponsorshipTypeService;
use Illuminate\Http\Request as LaravelRequest;
Expand Down Expand Up @@ -284,6 +285,7 @@ protected function getFilterRules(): array
'name' => ['==', '=@'],
'label' => ['==', '=@'],
'size' => ['==', '=@'],
'is_public' => ['=='],
];
}

Expand All @@ -296,6 +298,7 @@ protected function getFilterValidatorRules(): array
'name' => 'sometimes|required|string',
'label' => 'sometimes|required|string',
'size' => 'sometimes|required|string',
'is_public' => ['sometimes', new Boolean],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class SummitSponsorshipTypeSerializer extends AbstractSerializer
'Order' => 'order:json_int',
'ShouldDisplayOnExpoHallPage' => 'should_display_on_expo_hall_page:json_boolean',
'ShouldDisplayOnLobbyPage' => 'should_display_on_lobby_page:json_boolean',
'Public' => 'is_public:json_boolean',
];

protected static $expand_mappings = [
Expand All @@ -56,4 +57,4 @@ final class SummitSponsorshipTypeSerializer extends AbstractSerializer
'has' => 'hasType'
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public static function populate(SummitSponsorshipType $type, array $payload):Sum
if(isset($payload['should_display_on_expo_hall_page']))
$type->setShouldDisplayOnExpoHallPage(boolval($payload['should_display_on_expo_hall_page']));

if(isset($payload['is_public']))
$type->setPublic(boolval($payload['is_public']));

return $type;
}
}
}
10 changes: 9 additions & 1 deletion app/Models/Foundation/Summit/SummitSponsorshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ public function __construct()
$this->is_public = true;
}

public function isPublic():bool{
return $this->is_public;
}

public function setPublic(bool $is_public):void{
$this->is_public = $is_public;
}

/**
* @return int
*/
Expand Down Expand Up @@ -475,4 +483,4 @@ public function setShouldDisplayOnLobbyPage(bool $should_display_on_lobby_page):
$this->should_display_on_lobby_page = $should_display_on_lobby_page;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ protected function applyExtraJoins(QueryBuilder $query, ?Filter $filter = null,
protected function getFilterMappings()
{
return [
'name' => 't.name:json_string',
'label' => 't.label:json_string',
'size' => 't.size:json_string',
'name' => Filter::buildStringField('t.name'),
'label' => Filter::buildStringField('t.label'),
'size' => Filter::buildStringField('t.size'),
'summit_id' => 's.id',
'is_public' => Filter::buildBooleanField('e.is_public'),
];
}

Expand All @@ -70,4 +71,4 @@ protected function getBaseEntity()
{
return SummitSponsorshipType::class;
}
}
}
1 change: 1 addition & 0 deletions app/Swagger/Models/SummitSponsorshipTypeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
new OA\Property(property: 'order', type: 'integer', ),
new OA\Property(property: 'should_display_on_expo_hall_page', type: 'boolean', ),
new OA\Property(property: 'should_display_on_lobby_page', type: 'boolean', ),
new OA\Property(property: 'is_public', type: 'boolean', ),
new OA\Property(property: 'summit', ref: '#/components/schemas/Summit', description: "Summit object, only available when expanded"),
new OA\Property(property: 'type', ref: '#/components/schemas/SponsorshipType', description: "SponsorshipType object, only available when expanded"),
])
Expand Down
2 changes: 2 additions & 0 deletions app/Swagger/SummitSchemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ class PaginatedSummitSponsorshipTypesResponseSchema {}
new OA\Property(property: 'name', type: 'string', example: 'platinum'),
new OA\Property(property: 'label', type: 'string', example: 'Platinum'),
new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes),
new OA\Property(property: 'is_public', type: 'boolean', example: true),
]
)]
class SummitSponsorshipTypeCreateRequestSchema {}
Expand All @@ -436,6 +437,7 @@ class SummitSponsorshipTypeCreateRequestSchema {}
new OA\Property(property: 'label', type: 'string', example: 'Platinum'),
new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes),
new OA\Property(property: 'order', type: 'integer', example: 1, minimum: 1),
new OA\Property(property: 'is_public', type: 'boolean', example: true),
]
)]
class SummitSponsorshipTypeUpdateRequestSchema {}
Expand Down
63 changes: 62 additions & 1 deletion tests/oauth2/OAuth2SummitSponsorshipTypeApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function testAdd(){
'sponsor_page_use_schedule_widget' => false,
'sponsor_page_use_banner_widget' => true,
'type_id' => self::$testSponsorshipType->getId(),
'is_public' => false,
];

$headers = [
Expand All @@ -105,6 +106,7 @@ public function testAdd(){
$this->assertTrue(!is_null($summit_sponsorship_type));
$this->assertTrue($summit_sponsorship_type->widget_title === 'test');
$this->assertTrue(property_exists($summit_sponsorship_type, 'type'));
$this->assertTrue($summit_sponsorship_type->is_public === false);
}

public function testUpdate(){
Expand Down Expand Up @@ -146,6 +148,7 @@ public function testUpdate(){
$this->assertTrue(!is_null($summit_sponsorship_type));
$this->assertTrue($summit_sponsorship_type->widget_title === 'test');
$this->assertTrue(property_exists($summit_sponsorship_type, 'type'));
$this->assertTrue($summit_sponsorship_type->is_public === true);

$params = [
'id' => self::$summit->getId(),
Expand All @@ -155,7 +158,8 @@ public function testUpdate(){

$data = [
'widget_title' => 'test update',
'order' => 1
'order' => 1,
'is_public' => false,
];

$response = $this->action(
Expand All @@ -175,6 +179,7 @@ public function testUpdate(){
$this->assertTrue(!is_null($summit_sponsorship_type));
$this->assertTrue($summit_sponsorship_type->widget_title === 'test update');
$this->assertTrue($summit_sponsorship_type->order === 1);
$this->assertTrue($summit_sponsorship_type->is_public === false);
}

public function testDelete(){
Expand Down Expand Up @@ -332,6 +337,62 @@ public function testGetAllBySummitId(){
$this->assertNotEmpty($page->data);
}

public function testGetAllBySummitIdFilterByIsPublic(){

$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];

// the summit fixture already has 2 default sponsorship types, both public by default
$params = [
'id' => self::$summit->getId(),
];

$data = [
'type_id' => self::$testSponsorshipType->getId(),
'is_public' => false,
];

$response = $this->action(
"POST",
"OAuth2SummitSponsorshipTypeApiController@add",
$params,
[],
[],
[],
$headers,
json_encode($data)
);

$this->assertResponseStatus(201);
$new_type = json_decode($response->getContent());
$this->assertTrue($new_type->is_public === false);

$params = [
'id' => self::$summit->getId(),
'filter' => 'is_public==false',
];

$response = $this->action(
"GET",
"OAuth2SummitSponsorshipTypeApiController@getAllBySummit",
$params,
[],
[],
[],
$headers
);

$content = $response->getContent();
$this->assertResponseStatus(200);

$page = json_decode($content);
$this->assertTrue(!is_null($page));
$this->assertEquals(1, $page->total);
$this->assertEquals($new_type->id, $page->data[0]->id);
}

public function testAddBadgeImage(){

$params = [
Expand Down
Loading