Skip to content

Commit

Permalink
CC Errors fixed from testing
Browse files Browse the repository at this point in the history
  • Loading branch information
BradHN1 committed Oct 16, 2023
1 parent 0ccbbc6 commit 8bfd23e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/carbon_calculator/carbonCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .foodWaste import EvalLowCarbonDiet, EvalReduceWaste, EvalCompost
from .landscaping import EvalReduceLawnSize, EvalReduceLawnCare, EvalRakeOrElecBlower, EvalElectricMower

CALCULATOR_VERSION = "4.0.2"
CALCULATOR_VERSION = "4.0.3"
QUESTIONS_DATA = BASE_DIR + "/carbon_calculator/content/Questions.csv"
ACTIONS_DATA = BASE_DIR + "/carbon_calculator/content/Actions.csv"
DEFAULTS_DATA = BASE_DIR + "/carbon_calculator/content/defaults.csv"
Expand Down Expand Up @@ -417,6 +417,18 @@ def __init__(self,name):
self.text = "" # "Explanation for the calculated results."
self.picture = ""

status, actionInfo = QuerySingleAction(self.name)
if status == VALID_QUERY:
self.id = actionInfo["id"]
self.title = actionInfo["title"]
self.description = actionInfo["description"]
self.helptext = actionInfo["helptext"]
self.questions = actionInfo["questionInfo"] # question with list of valid responses.
self.average_points = actionInfo["average_points"]
self.picture = actionInfo["picture"]
self.initialized = True


def Query(self):
status, actionInfo = QuerySingleAction(self.name)
if not self.id and status == VALID_QUERY:
Expand Down
9 changes: 5 additions & 4 deletions src/carbon_calculator/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ def QuerySingleAction(name,event_tag=""):

questionInfo = []
for question in q.questions:
qq = CalculatorQuestion(question, event_tag)
# a question with no text is not to be included; this is how depending on the event_tag some questions would not be asked.
if len(qq.questionText)>0:
questionInfo.append(jsons.dump(qq))
if question != '':
qq = CalculatorQuestion(question, event_tag)
# a question with no text is not to be included; this is how depending on the event_tag some questions would not be asked.
if len(qq.questionText)>0:
questionInfo.append(jsons.dump(qq))

picture = ""
if q.picture:
Expand Down

0 comments on commit 8bfd23e

Please sign in to comment.