Currency field as dropdown

This commit is contained in:
bashrc committed 2021-08-07 18:44:25 +01:00
1 parent 3fe41d6c85
commit 83c631104a
3 files changed
+80 -59

No files matched your search

+2 -56
View File
@@ -22,6 +22,7 @@ from utils import isPGPEncrypted
from utils import containsPGPPublicKey
from utils import acctDir
from utils import isfloat
from utils import getCurrencies
from petnames import getPetName
@@ -1092,62 +1093,7 @@ def limitRepeatedWords(text: str, maxRepeats: int) -> str:
def getPriceFromString(priceStr: str) -> (str, str):
"""Returns the item price and currency
"""
currencies = {
"J$": "JMD",
"£": "GBP",
"€": "EUR",
"؋": "AFN",
"ƒ": "AWG",
"₼": "AZN",
"Br": "BYN",
"BZ$": "BZD",
"$b": "BOB",
"KM": "BAM",
"P": "BWP",
"лв": "BGN",
"R$": "BRL",
"៛": "KHR",
"$U": "UYU",
"RD$": "DOP",
"$": "USD",
"₡": "CRC",
"kn": "HRK",
"₱": "CUP",
"Kč": "CZK",
"kr": "NOK",
"¢": "GHS",
"Q": "GTQ",
"L": "HNL",
"Ft": "HUF",
"Rp": "IDR",
"﷼": "IRR",
"₪": "ILS",
"¥": "JPY",
"₩": "KRW",
"₭": "LAK",
"ден": "MKD",
"RM": "MYR",
"₨": "MUR",
"₮": "MNT",
"MT": "MZN",
"C$": "NIO",
"₦": "NGN",
"Gs": "PYG",
"zł": "PLN",
"lei": "RON",
"₽": "RUB",
"Дин": "RSD",
"S": "SOS",
"R": "ZAR",
"CHF": "CHF",
"NT$": "TWD",
"฿": "THB",
"TT$": "TTD",
"₴": "UAH",
"Bs": "VEF",
"₫": "VND",
"Z$": "ZQD"
}
currencies = getCurrencies()
for symbol, name in currencies.items():
if symbol in priceStr:
price = priceStr.replace(symbol, '')
+63
View File
@@ -2730,3 +2730,66 @@ def isGroupActor(baseDir: str, actor: str, personCache: {},
print('Group type found in ' + cachedActorFilename)
return True
return False
def getCurrencies() -> {}:
"""Returns a dictionary of currencies
"""
return {
"CA$": "CAD",
"J$": "JMD",
"£": "GBP",
"€": "EUR",
"؋": "AFN",
"ƒ": "AWG",
"₼": "AZN",
"Br": "BYN",
"BZ$": "BZD",
"$b": "BOB",
"KM": "BAM",
"P": "BWP",
"лв": "BGN",
"R$": "BRL",
"៛": "KHR",
"$U": "UYU",
"RD$": "DOP",
"$": "USD",
"₡": "CRC",
"kn": "HRK",
"₱": "CUP",
"Kč": "CZK",
"kr": "NOK",
"¢": "GHS",
"Q": "GTQ",
"L": "HNL",
"Ft": "HUF",
"Rp": "IDR",
"₹": "INR",
"﷼": "IRR",
"₪": "ILS",
"¥": "JPY",
"₩": "KRW",
"₭": "LAK",
"ден": "MKD",
"RM": "MYR",
"₨": "MUR",
"₮": "MNT",
"MT": "MZN",
"C$": "NIO",
"₦": "NGN",
"Gs": "PYG",
"zł": "PLN",
"lei": "RON",
"₽": "RUB",
"Дин": "RSD",
"S": "SOS",
"R": "ZAR",
"CHF": "CHF",
"NT$": "TWD",
"฿": "THB",
"TT$": "TTD",
"₴": "UAH",
"Bs": "VEF",
"₫": "VND",
"Z$": "ZQD"
}
+15 -3
View File
@@ -14,6 +14,7 @@ from utils import getDomainFromActor
from utils import getMediaFormats
from utils import getConfigParam
from utils import acctDir
from utils import getCurrencies
from webapp_utils import getBannerFile
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
@@ -364,6 +365,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
categoryTypes = ("food", "clothes", "tool")
catStr = translate['Category of shared item. eg. clothing']
extraFields += '<label class="labels">' + catStr + '</label><br>\n'
extraFields += ' <select id="themeDropdown" ' + \
'name="category" class="theme">'
for category in categoryTypes:
@@ -373,6 +375,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
extraFields += ' <option value="' + \
translatedCategory + '">' + \
translatedCategory + '</option>'
extraFields += '<br>'
extraFields += \
editNumberField(translate['Duration of listing in days'],
@@ -386,9 +389,18 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
extraFields += \
editCurrencyField(translate['Price'] + ':', 'itemPrice', '0.00',
'0.00', True)
extraFields += '<br>' + \
editTextField(translate['Currency'] + ':', 'itemCurrency', 'EUR',
'EUR / GBP / USD ...', True)
extraFields += '<br>'
extraFields += \
'<label class="labels">' + translate['Currency'] + '</label><br>\n'
currencies = getCurrencies()
currencies.sort()
extraFields += ' <select id="themeDropdown" ' + \
'name="itemCurrency" class="theme">'
for symbol, currName in currencies.items():
extraFields += ' <option value="' + \
currName + '">' + \
currName + ' ' + symbol + '</option>'
extraFields += '</div>\n'
citationsStr = ''