Fix tests

main
Bob Mottram 2021-07-24 12:47:51 +01:00
parent c4db90c66f
commit 7d47bf4a38
3 changed files with 27 additions and 7 deletions

View File

@ -2327,8 +2327,8 @@ if args.testdata:
httpPrefix, nickname, domain, port,
"spanner",
"It's a spanner",
"img/shares1.png",
"tool",
"img/shares1.png",
1, "tool",
"mechanical",
"City",
"2 months",
@ -2338,7 +2338,7 @@ if args.testdata:
"witch hat",
"Spooky",
"img/shares2.png",
"hat",
1, "hat",
"clothing",
"City",
"3 months",

View File

@ -18,6 +18,7 @@ from webapp_utils import getBannerFile
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import editTextField
from webapp_utils import editNumberField
def _htmlFollowingDataList(baseDir: str, nickname: str,
@ -354,6 +355,9 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
translate['Description of the item being shared'] + '...'
endpoint = 'newshare'
extraFields = '<div class="container">\n'
extraFields += \
editNumberField(translate['Quantity'],
'itemQty', 1, 1, 999999, 1)
extraFields += \
editTextField(translate['Quantity'] + ':',
'itemQty', '1')
@ -362,11 +366,10 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
'itemType', '')
catStr = translate['Category of shared item. eg. clothing']
extraFields += editTextField(catStr + ':', 'category', '')
extraFields += '<br>'
extraFields += \
' <br><label class="labels">' + \
translate['Duration of listing in days'] + ':</label>\n'
extraFields += ' <input type="number" name="duration" ' + \
'min="1" max="365" step="1" value="14">\n'
editNumberField(translate['Duration of listing in days'],
'duration', 14, 1, 365, 1)
extraFields += '</div>\n'
extraFields += '<div class="container">\n'
cityOrLocStr = translate['City or location of the shared item']

View File

@ -1142,6 +1142,23 @@ def editTextField(label: str, name: str, value: str = "",
value + '"' + placeholderStr + '>\n'
def editNumberField(label: str, name: str, value: int = 1,
minValue: int = 1, maxValue: int = 999999,
placeholder: int = 1) -> str:
"""Returns html for editing an integer number field
"""
if value is None:
value = ''
placeholderStr = ''
if placeholder:
placeholderStr = ' placeholder="' + str(placeholder) + '"'
return \
'<label class="labels">' + label + '</label><br>\n' + \
' <input type="number" name="' + name + '" value="' + \
str(value) + '"' + placeholderStr + ' ' + \
'min="' + str(minValue) + '" max="' + str(maxValue) + '" step="1">\n'
def editCheckBox(label: str, name: str, checked: bool = False) -> str:
"""Returns html for editing a checkbox field
"""