1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

add vote action started, changed some routes

This commit is contained in:
Baptiste Lemoine 2019-11-12 12:04:38 +01:00
parent d1dd8955a3
commit 216d1902cc

View File

@ -46,7 +46,7 @@ class DefaultController extends AbstractController {
/**
* @Get(
* path = "/poll/all",
* path = "/polls",
* name = "get_all_polls"
* )
*/
@ -64,7 +64,7 @@ class DefaultController extends AbstractController {
/**
* @Post(
* path = "/poll/new",
* path = "/poll",
* name = "new_polls",
* requirements = {"creator"="\w+"}
* )
@ -125,7 +125,7 @@ class DefaultController extends AbstractController {
* @Get(
* path = "/poll/{id}/comments",
* name = "get_poll_comment",
* requirements = {"id"="\d+"}
* requirements = {"poll_id"="\d+"}
* )
*/
public function getPollCommentsAction( Poll $poll ) {
@ -140,7 +140,7 @@ class DefaultController extends AbstractController {
* @Get(
* path = "/poll/{id}",
* name = "get_poll",
* requirements = {"id"="\d+"}
* requirements = {"poll_id"="\d+"}
* )
*/
public function getPollConfig( Poll $poll ) {
@ -160,13 +160,14 @@ class DefaultController extends AbstractController {
*/
public function updatePollConfig( Poll $poll, Request $request ) {
// TODO check validity of request
// update only if we have the admin key
$em = $this->getDoctrine()->getManager();
$em->persist( $poll );
$em->flush();
return $this->json( [
'message' => 'you updated the poll',
'message' => 'you updated the poll ' . $poll->getTitle(),
] );
}
@ -214,6 +215,13 @@ class DefaultController extends AbstractController {
201 );
}
function newVoteAction( Poll $poll ) {
return $this->json( [
'message' => 'you voted on the poll',
],
201 );
}
/**
* @Delete(