From b76e16294a9eeef985427dec6e8a556967237eb0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Jul 2020 11:20:11 +0200 Subject: [PATCH] Can cancel the response to a survey --- src/controllers/routes.rs | 3 +++ src/controllers/surveys_controller.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index fa10f73..e43d548 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -231,11 +231,14 @@ pub fn get_routes() -> Vec { // Likes controller Route::post("/likes/update", Box::new(likes_controller::update)), + // Surveys controller Route::post("/surveys/get_info", Box::new(surveys_controller::get_info_single)), Route::post("/surveys/send_response", Box::new(surveys_controller::send_response)), + Route::post("/surveys/cancel_response", Box::new(surveys_controller::cancel_response)), + // Movies controller Route::post("/movies/get_list", Box::new(movies_controller::get_list)), diff --git a/src/controllers/surveys_controller.rs b/src/controllers/surveys_controller.rs index af6a335..c82c641 100644 --- a/src/controllers/surveys_controller.rs +++ b/src/controllers/surveys_controller.rs @@ -43,3 +43,12 @@ pub fn send_response(r: &mut HttpRequestHandler) -> RequestResult { r.success("Choice saved!") } + +/// Cancel a response to a survey +pub fn cancel_response(r: &mut HttpRequestHandler) -> RequestResult { + let survey_id = r.post_survey_id_from_post_id("postID", PostAccessLevel::BASIC_ACCESS)?; + + survey_helper::cancel_response(r.user_id_ref()?, survey_id)?; + + r.success("Response cancelled") +} \ No newline at end of file