adding symptoms to UI
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from HtmlTransformerUtil import HtmlTransformerUtil
|
||||
from DateProvider import DateProvider
|
||||
from SymptomsCausedByVaccines.HtmlUtils import getVaccineOptions
|
||||
from SymptomsCausedByVaccines.HtmlUtils import getVaccineOptions, getSymptomOptions
|
||||
from SymptomsCausedByVaccines.OptionsSetter import OptionsSetter
|
||||
|
||||
|
||||
def updateHtmlFile(vaccines, htmlFile, lastUpdated):
|
||||
_saveVaccineOptions(
|
||||
vaccineOptions = getVaccineOptions(vaccines),
|
||||
def updateHtmlFile(vaccines, symptoms, htmlFile, lastUpdated):
|
||||
_saveOptions(
|
||||
options = getVaccineOptions(vaccines),
|
||||
htmlFile = htmlFile,
|
||||
vaccineSelectElementId = 'vaccineSelect')
|
||||
selectElementId = 'vaccineSelect')
|
||||
|
||||
_saveOptions(
|
||||
options = getSymptomOptions(symptoms),
|
||||
htmlFile = htmlFile,
|
||||
selectElementId = 'symptomSelect')
|
||||
|
||||
saveLastUpdated2HtmlFile(
|
||||
lastUpdated = lastUpdated,
|
||||
htmlFile = htmlFile,
|
||||
lastUpdatedElementId = 'last_updated')
|
||||
|
||||
def _saveVaccineOptions(vaccineOptions, htmlFile, vaccineSelectElementId):
|
||||
def _saveOptions(options, htmlFile, selectElementId):
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file=htmlFile,
|
||||
soupTransformer = lambda soup:
|
||||
BeautifulSoup(
|
||||
OptionsSetter().setOptions(
|
||||
html = str(soup),
|
||||
selectElementId = vaccineSelectElementId,
|
||||
options = vaccineOptions),
|
||||
selectElementId = selectElementId,
|
||||
options = options),
|
||||
'lxml'))
|
||||
|
||||
def saveLastUpdated2HtmlFile(lastUpdated, htmlFile, lastUpdatedElementId):
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
def getVaccineOptions(vaccines):
|
||||
return ['<option hidden disabled selected value>Select Vaccine</option>'] + _getVaccineOptions(vaccines)
|
||||
return ['<option hidden disabled selected value>Select Vaccine</option>'] + _getOptions(vaccines)
|
||||
|
||||
|
||||
def _getVaccineOptions(vaccines):
|
||||
return [_getVaccineOption(vaccine) for vaccine in vaccines]
|
||||
def getSymptomOptions(symptoms):
|
||||
return ['<option hidden disabled selected value>Select Symptom</option>'] + _getOptions(symptoms)
|
||||
|
||||
|
||||
def _getVaccineOption(vaccine):
|
||||
return '<option value="{vaccine}">{vaccine}</option>'.format(vaccine=vaccine)
|
||||
def _getOptions(values):
|
||||
return [_getOption(value) for value in values]
|
||||
|
||||
|
||||
def _getOption(value):
|
||||
return '<option value="{value}">{value}</option>'.format(value=value)
|
||||
|
||||
Reference in New Issue
Block a user