Fixed delete presentation for CFP
Change-Id: Iaa2bcc7d328bc8cbafcd39b1b992de09fb042f39
This commit is contained in:
parent
8fc781dc69
commit
a0ebcb735d
@ -452,12 +452,18 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function deletePresentation($presentation_id){
|
||||
public function deletePresentation($summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$current_member_id = $this->resource_server_context->getCurrentUserExternalId();
|
||||
if (is_null($current_member_id))
|
||||
return $this->error403();
|
||||
@ -467,7 +473,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
if(is_null($member))
|
||||
return $this->error403();
|
||||
|
||||
$this->presentation_service->deletePresentation($member, $presentation_id);
|
||||
$this->presentation_service->deletePresentation($summit, $member, $presentation_id);
|
||||
|
||||
return $this->deleted();
|
||||
|
||||
|
@ -674,10 +674,17 @@ class Summit extends SilverstripeBaseModel
|
||||
*/
|
||||
public function addEvent(SummitEvent $event)
|
||||
{
|
||||
if($this->events->contains($event)) return;
|
||||
$this->events->add($event);
|
||||
$event->setSummit($this);
|
||||
}
|
||||
|
||||
public function removeEvent(SummitEvent $event){
|
||||
if(!$this->events->contains($event)) return;
|
||||
$this->events->removeElement($event);
|
||||
$event->clearSummit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return File
|
||||
*/
|
||||
|
@ -80,11 +80,12 @@ interface IPresentationService
|
||||
public function completePresentationSubmission(Summit $summit, $presentation_id, Member $member);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $presentation_id
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function deletePresentation(Member $member, $presentation_id);
|
||||
public function deletePresentation(Summit $summit, Member $member, $presentation_id);
|
||||
}
|
@ -493,21 +493,22 @@ final class PresentationService
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $presentation_id
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function deletePresentation(Member $member, $presentation_id)
|
||||
public function deletePresentation(Summit $summit, Member $member, $presentation_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($member, $presentation_id) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $member, $presentation_id) {
|
||||
|
||||
$current_speaker = $this->speaker_repository->getByMember($member);
|
||||
if(is_null($current_speaker))
|
||||
throw new EntityNotFoundException(sprintf("member %s does not has a speaker profile", $member->getId()));
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation))
|
||||
throw new EntityNotFoundException(sprintf("presentation %s not found", $presentation_id));
|
||||
|
||||
@ -520,7 +521,8 @@ final class PresentationService
|
||||
$presentation_id
|
||||
));
|
||||
|
||||
$this->event_repository->delete($presentation);
|
||||
$summit->removeEvent($presentation);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -30,16 +30,10 @@ class OAuth2PresentationSubmissionTest extends ProtectedApiTest
|
||||
'social_description' => 'this is a social description',
|
||||
'level' => 'N/A',
|
||||
'attendees_expected_learnt' => 'super duper',
|
||||
'type_id' => 171,
|
||||
'type_id' => 182,
|
||||
'track_id' => 262,
|
||||
'attending_media' => true,
|
||||
'links' => ['https://www.google.com'],
|
||||
'extra_questions' => [
|
||||
[
|
||||
'id' => 24,
|
||||
'value' => 'test',
|
||||
]
|
||||
],
|
||||
'tags' => ['Upstream Development']
|
||||
];
|
||||
|
||||
@ -66,4 +60,34 @@ class OAuth2PresentationSubmissionTest extends ProtectedApiTest
|
||||
$this->assertEquals($title, $presentation->title);
|
||||
return $presentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
*/
|
||||
public function testDeletePresentation($summit_id = 25){
|
||||
$new_presentation = $this->testSubmitPresentation($summit_id);
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'presentation_id' => $new_presentation->id,
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"DELETE",
|
||||
"OAuth2PresentationApiController@deletePresentation",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
''
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(204);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user