mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-10-31 01:24:43 +00:00 
			
		
		
		
	Auto-block choices creation if the maximum is reached
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| import { Survey, SurveyChoice } from "../entities/Survey"; | ||||
| import { RequestHandler } from "../entities/RequestHandler"; | ||||
| import { SurveyHelper } from "../helpers/SurveyHelper"; | ||||
| import { SurveyHelper, MAXIMUM_NUMBER_SURVEY_CHOICES } from "../helpers/SurveyHelper"; | ||||
| import { SurveyResponse } from "../entities/SurveyResponse"; | ||||
| import { PostAccessLevel } from "../entities/Post"; | ||||
|  | ||||
| @@ -66,6 +66,10 @@ export class SurveyController { | ||||
| 		// Create the choice | ||||
| 		await SurveyHelper.CreateChoice(surveyID, newChoice); | ||||
|  | ||||
| 		// Auto-block creation of new choices if limit is reached | ||||
| 		if(survey.choices.length + 1 >= MAXIMUM_NUMBER_SURVEY_CHOICES) | ||||
| 			await SurveyHelper.BlockNewChoicesCreation(surveyID); | ||||
|  | ||||
| 		h.success(); | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -25,6 +25,11 @@ const SURVEY_CHOICES_TABLE = "sondage_choix"; | ||||
|  */ | ||||
| const SURVEY_RESPONSE_TABLE = "sondage_reponse"; | ||||
|  | ||||
| /** | ||||
|  * Maximum number of choices for a survey | ||||
|  */ | ||||
| export const MAXIMUM_NUMBER_SURVEY_CHOICES = 20; | ||||
|  | ||||
| /** | ||||
|  * Survey helper | ||||
|  */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user