From e9acfbddd5ecabcb524324445a903ac2fe338d8d Mon Sep 17 00:00:00 2001 From: chamil321 Date: Wed, 29 Jul 2020 16:46:34 +0530 Subject: [PATCH] Fix wantCode user input --- subscriber/src/subscriber/save.bal | 4 ++-- subscriber/src/subscriber/subscriber.bal | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/subscriber/src/subscriber/save.bal b/subscriber/src/subscriber/save.bal index 5225013..bb36d0f 100644 --- a/subscriber/src/subscriber/save.bal +++ b/subscriber/src/subscriber/save.bal @@ -102,7 +102,7 @@ function saveImagePdf(map imageJson) { # + return - returns the base name for the file function getPresidentialFileNameBase(string electionCode, map result) returns string { // start with sequence # and type code - string name = (wantCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" + + string name = (addCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" + (result.'type.toString() == PRESIDENTIAL_RESULT ? "PE1" : "PE2") + "-"; string resultLevel = result.level.toString(); @@ -140,7 +140,7 @@ function getPresidentialFileNameBase(string electionCode, map result) retu # + return - returns the base name for the file function getParliamentaryFileNameBase(string electionCode, map result) returns string { // start with sequence # and type code - string name = (wantCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" + + string name = (addCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" + result.'type.toString() + "-"; string resultLevel = result.level.toString(); diff --git a/subscriber/src/subscriber/subscriber.bal b/subscriber/src/subscriber/subscriber.bal index 82a89f7..5bd856f 100644 --- a/subscriber/src/subscriber/subscriber.bal +++ b/subscriber/src/subscriber/subscriber.bal @@ -10,7 +10,7 @@ boolean wantXml = false; boolean wantHtml = false; boolean sortedHtml = false; -boolean wantCode = false; +boolean addCode = false; public type ElectionType ELECTION_TYPE_PRESIDENTIAL|ELECTION_TYPE_PARLIAMENTARY; @@ -38,6 +38,9 @@ public function main (string? username = (), // my username generateHtml = generateParliamentaryResultHtml; } + // check whether the user wants electionCode in the filename + addCode = <@untainted>wantCode; + // check what format the user wants results in wantJson = <@untainted>'json; wantXml = <@untainted>'xml;