Add quantity to shared items

main
Bob Mottram 2021-07-24 12:30:46 +01:00
parent d70badb76b
commit 67747bad72
23 changed files with 70 additions and 23 deletions

View File

@ -13627,6 +13627,8 @@ class PubServer(BaseHTTPRequestHandler):
return 1 return 1
return -1 return -1
elif postType == 'newshare': elif postType == 'newshare':
if not fields.get('itemQty'):
return -1
if not fields.get('itemType'): if not fields.get('itemType'):
return -1 return -1
if not fields.get('category'): if not fields.get('category'):
@ -13646,6 +13648,10 @@ class PubServer(BaseHTTPRequestHandler):
self.server.baseDir, self.server.baseDir,
nickname, nickname,
self.server.domain) self.server.domain)
itemQty = 1
if fields['itemQty']:
if fields['itemQty'].isdigit():
itemQty = int(fields['itemQty'])
addShare(self.server.baseDir, addShare(self.server.baseDir,
self.server.httpPrefix, self.server.httpPrefix,
nickname, nickname,
@ -13653,7 +13659,7 @@ class PubServer(BaseHTTPRequestHandler):
fields['subject'], fields['subject'],
fields['message'], fields['message'],
filename, filename,
fields['itemType'], itemQty, fields['itemType'],
fields['category'], fields['category'],
fields['location'], fields['location'],
durationStr, durationStr,

View File

@ -558,6 +558,9 @@ parser.add_argument('--summary', dest='summary', type=str,
parser.add_argument('--itemImage', dest='itemImage', type=str, parser.add_argument('--itemImage', dest='itemImage', type=str,
default=None, default=None,
help='Filename of an image for an item being shared') help='Filename of an image for an item being shared')
parser.add_argument('--itemQty', dest='itemQty', type=int,
default=1,
help='Quantity of items being shared')
parser.add_argument('--itemType', dest='itemType', type=str, parser.add_argument('--itemType', dest='itemType', type=str,
default=None, default=None,
help='Type of item being shared') help='Type of item being shared')
@ -1246,6 +1249,10 @@ if args.itemName:
'with the --summary option') 'with the --summary option')
sys.exit() sys.exit()
if not args.itemQty:
print('Specify a quantity of shared items with the --itemQty option')
sys.exit()
if not args.itemType: if not args.itemType:
print('Specify a type of shared item with the --itemType option') print('Specify a type of shared item with the --itemType option')
sys.exit() sys.exit()
@ -1277,6 +1284,7 @@ if args.itemName:
args.itemName, args.itemName,
args.summary, args.summary,
args.itemImage, args.itemImage,
args.itemQty,
args.itemType, args.itemType,
args.itemCategory, args.itemCategory,
args.location, args.location,

View File

@ -97,7 +97,7 @@ def _addShareDurationSec(duration: str, published: str) -> int:
def addShare(baseDir: str, def addShare(baseDir: str,
httpPrefix: str, nickname: str, domain: str, port: int, httpPrefix: str, nickname: str, domain: str, port: int,
displayName: str, summary: str, imageFilename: str, displayName: str, summary: str, imageFilename: str,
itemType: str, itemCategory: str, location: str, itemQty: int, itemType: str, itemCategory: str, location: str,
duration: str, debug: bool, city: str) -> None: duration: str, debug: bool, city: str) -> None:
"""Adds a new share """Adds a new share
""" """
@ -151,6 +151,7 @@ def addShare(baseDir: str,
"displayName": displayName, "displayName": displayName,
"summary": summary, "summary": summary,
"imageUrl": imageUrl, "imageUrl": imageUrl,
"itemQty": itemQty,
"itemType": itemType, "itemType": itemType,
"category": itemCategory, "category": itemCategory,
"location": location, "location": location,
@ -321,7 +322,7 @@ def sendShareViaServer(baseDir, session,
fromDomain: str, fromPort: int, fromDomain: str, fromPort: int,
httpPrefix: str, displayName: str, httpPrefix: str, displayName: str,
summary: str, imageFilename: str, summary: str, imageFilename: str,
itemType: str, itemCategory: str, itemQty: int, itemType: str, itemCategory: str,
location: str, duration: str, location: str, duration: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
debug: bool, projectVersion: str) -> {}: debug: bool, projectVersion: str) -> {}:
@ -347,6 +348,7 @@ def sendShareViaServer(baseDir, session,
"type": "Offer", "type": "Offer",
"displayName": displayName, "displayName": displayName,
"summary": summary, "summary": summary,
"itemQty": itemQty,
"itemType": itemType, "itemType": itemType,
"category": itemCategory, "category": itemCategory,
"location": location, "location": location,
@ -545,6 +547,10 @@ def outboxShareUpload(baseDir: str, httpPrefix: str,
if debug: if debug:
print('DEBUG: summary missing from Offer') print('DEBUG: summary missing from Offer')
return return
if not messageJson['object'].get('itemQty'):
if debug:
print('DEBUG: itemQty missing from Offer')
return
if not messageJson['object'].get('itemType'): if not messageJson['object'].get('itemType'):
if debug: if debug:
print('DEBUG: itemType missing from Offer') print('DEBUG: itemType missing from Offer')
@ -566,6 +572,7 @@ def outboxShareUpload(baseDir: str, httpPrefix: str,
messageJson['object']['displayName'], messageJson['object']['displayName'],
messageJson['object']['summary'], messageJson['object']['summary'],
messageJson['object']['imageFilename'], messageJson['object']['imageFilename'],
messageJson['object']['itemQty'],
messageJson['object']['itemType'], messageJson['object']['itemType'],
messageJson['object']['itemCategory'], messageJson['object']['itemCategory'],
messageJson['object']['location'], messageJson['object']['location'],

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "عوامل المستخدم المحظورة", "Blocked User Agents": "عوامل المستخدم المحظورة",
"Notify me when this account posts": "أعلمني عندما ينشر الحساب هذا", "Notify me when this account posts": "أعلمني عندما ينشر الحساب هذا",
"Languages": "اللغات", "Languages": "اللغات",
"Translated": "تترجم" "Translated": "تترجم",
"Quantity": "كمية"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Agents d'usuari bloquejats", "Blocked User Agents": "Agents d'usuari bloquejats",
"Notify me when this account posts": "Aviseu-me quan publiqui aquest compte", "Notify me when this account posts": "Aviseu-me quan publiqui aquest compte",
"Languages": "Idiomes", "Languages": "Idiomes",
"Translated": "Traduït" "Translated": "Traduït",
"Quantity": "Quantitat"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Asiantau defnyddwyr wedi'u blocio", "Blocked User Agents": "Asiantau defnyddwyr wedi'u blocio",
"Notify me when this account posts": "Rhoi gwybod i mi pan fydd y cyfrifon cyfrif hwn", "Notify me when this account posts": "Rhoi gwybod i mi pan fydd y cyfrifon cyfrif hwn",
"Languages": "Ieithoedd", "Languages": "Ieithoedd",
"Translated": "Chyfieithwyd" "Translated": "Chyfieithwyd",
"Quantity": "Symiau"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Blockierte Benutzeragenten", "Blocked User Agents": "Blockierte Benutzeragenten",
"Notify me when this account posts": "Benachrichtigen Sie mich, wenn dieses Konto postet", "Notify me when this account posts": "Benachrichtigen Sie mich, wenn dieses Konto postet",
"Languages": "Sprachen", "Languages": "Sprachen",
"Translated": "Übersetzt" "Translated": "Übersetzt",
"Quantity": "Menge"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Blocked User Agents", "Blocked User Agents": "Blocked User Agents",
"Notify me when this account posts": "Notify me when this account posts", "Notify me when this account posts": "Notify me when this account posts",
"Languages": "Languages", "Languages": "Languages",
"Translated": "Translated" "Translated": "Translated",
"Quantity": "Quantity"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Agentes de usuario bloqueados", "Blocked User Agents": "Agentes de usuario bloqueados",
"Notify me when this account posts": "Notifíqueme cuando se publique esta cuenta", "Notify me when this account posts": "Notifíqueme cuando se publique esta cuenta",
"Languages": "Idiomas", "Languages": "Idiomas",
"Translated": "Traducida" "Translated": "Traducida",
"Quantity": "Cantidad"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Agents d'utilisateur bloqués", "Blocked User Agents": "Agents d'utilisateur bloqués",
"Notify me when this account posts": "Avertissez-moi quand ce compte publie", "Notify me when this account posts": "Avertissez-moi quand ce compte publie",
"Languages": "Langues", "Languages": "Langues",
"Translated": "Traduite" "Translated": "Traduite",
"Quantity": "Quantité"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Gníomhairí úsáideora blocáilte", "Blocked User Agents": "Gníomhairí úsáideora blocáilte",
"Notify me when this account posts": "Cuir in iúl dom nuair a phostófar an cuntas seo", "Notify me when this account posts": "Cuir in iúl dom nuair a phostófar an cuntas seo",
"Languages": "Teangacha", "Languages": "Teangacha",
"Translated": "Aistrithe" "Translated": "Aistrithe",
"Quantity": "Cainníocht"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "अवरुद्ध उपयोगकर्ता एजेंट", "Blocked User Agents": "अवरुद्ध उपयोगकर्ता एजेंट",
"Notify me when this account posts": "यह खाता पोस्ट होने पर मुझे सूचित करें", "Notify me when this account posts": "यह खाता पोस्ट होने पर मुझे सूचित करें",
"Languages": "बोली", "Languages": "बोली",
"Translated": "अनुवाद" "Translated": "अनुवाद",
"Quantity": "मात्रा"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Agenti utente bloccati", "Blocked User Agents": "Agenti utente bloccati",
"Notify me when this account posts": "Avvisami quando questo account messaggi", "Notify me when this account posts": "Avvisami quando questo account messaggi",
"Languages": "Le lingue", "Languages": "Le lingue",
"Translated": "Tradotto" "Translated": "Tradotto",
"Quantity": "Quantità"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "ブロックされたユーザーエージェント", "Blocked User Agents": "ブロックされたユーザーエージェント",
"Notify me when this account posts": "この口座投稿を通知する", "Notify me when this account posts": "この口座投稿を通知する",
"Languages": "言語", "Languages": "言語",
"Translated": "翻訳" "Translated": "翻訳",
"Quantity": "量"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Karmendên bikarhêner asteng kirin", "Blocked User Agents": "Karmendên bikarhêner asteng kirin",
"Notify me when this account posts": "Dema ku ev postên hesabê min agahdar bikin", "Notify me when this account posts": "Dema ku ev postên hesabê min agahdar bikin",
"Languages": "Ziman", "Languages": "Ziman",
"Translated": "Wergerandin" "Translated": "Wergerandin",
"Quantity": "Jimarî"
} }

View File

@ -448,5 +448,6 @@
"Blocked User Agents": "Blocked User Agents", "Blocked User Agents": "Blocked User Agents",
"Notify me when this account posts": "Notify me when this account posts", "Notify me when this account posts": "Notify me when this account posts",
"Languages": "Languages", "Languages": "Languages",
"Translated": "Translated" "Translated": "Translated",
"Quantity": "Quantity"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Agentes de usuário bloqueados", "Blocked User Agents": "Agentes de usuário bloqueados",
"Notify me when this account posts": "Notifique-me quando esta conta posts", "Notify me when this account posts": "Notifique-me quando esta conta posts",
"Languages": "Línguas", "Languages": "Línguas",
"Translated": "Traduzida" "Translated": "Traduzida",
"Quantity": "Quantidade"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Заблокированные пользовательские агенты", "Blocked User Agents": "Заблокированные пользовательские агенты",
"Notify me when this account posts": "Сообщите мне, когда эта учетная запись", "Notify me when this account posts": "Сообщите мне, когда эта учетная запись",
"Languages": "Языки", "Languages": "Языки",
"Translated": "Перевод" "Translated": "Перевод",
"Quantity": "Количество"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "Wakala wa watumiaji waliozuiwa", "Blocked User Agents": "Wakala wa watumiaji waliozuiwa",
"Notify me when this account posts": "Nijulishe wakati akaunti hii ya akaunti.", "Notify me when this account posts": "Nijulishe wakati akaunti hii ya akaunti.",
"Languages": "Lugha", "Languages": "Lugha",
"Translated": "Ilitafsiriwa" "Translated": "Ilitafsiriwa",
"Quantity": "Wingi"
} }

View File

@ -452,5 +452,6 @@
"Blocked User Agents": "阻止用户代理商", "Blocked User Agents": "阻止用户代理商",
"Notify me when this account posts": "此帐户帖子时通知我", "Notify me when this account posts": "此帐户帖子时通知我",
"Languages": "语言", "Languages": "语言",
"Translated": "翻译" "Translated": "翻译",
"Quantity": "数量"
} }

View File

@ -354,6 +354,9 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
translate['Description of the item being shared'] + '...' translate['Description of the item being shared'] + '...'
endpoint = 'newshare' endpoint = 'newshare'
extraFields = '<div class="container">\n' extraFields = '<div class="container">\n'
extraFields += \
editTextField(translate['Quantity'] + ':',
'itemQty', '1')
extraFields += \ extraFields += \
editTextField(translate['Type of shared item. eg. hat'] + ':', editTextField(translate['Type of shared item. eg. hat'] + ':',
'itemType', '') 'itemType', '')

View File

@ -175,9 +175,12 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
sharedItem['imageUrl'] + \ sharedItem['imageUrl'] + \
'" alt="Item image"></a>\n' '" alt="Item image"></a>\n'
sharedItemsForm += \ sharedItemsForm += \
'<p>' + sharedItem['summary'] + '</p>\n' '<p>' + sharedItem['summary'] + '</p>\n<p>'
sharedItemsForm += \ sharedItemsForm += \
'<p><b>' + translate['Type'] + \ '<b>' + translate['Quantity'] + \
':</b> ' + str(sharedItem['itemQty']) + ' '
sharedItemsForm += \
'<b>' + translate['Type'] + \
':</b> ' + sharedItem['itemType'] + ' ' ':</b> ' + sharedItem['itemType'] + ' '
sharedItemsForm += \ sharedItemsForm += \
'<b>' + translate['Category'] + \ '<b>' + translate['Category'] + \

View File

@ -821,8 +821,11 @@ def htmlIndividualShare(actor: str, item: {}, translate: {},
'<img loading="lazy" src="' + item['imageUrl'] + \ '<img loading="lazy" src="' + item['imageUrl'] + \
'" alt="' + translate['Item image'] + '">\n</a>\n' '" alt="' + translate['Item image'] + '">\n</a>\n'
profileStr += '<p>' + item['summary'] + '</p>\n' profileStr += '<p>' + item['summary'] + '</p>\n'
profileStr += '<p>'
profileStr += \ profileStr += \
'<p><b>' + translate['Type'] + ':</b> ' + item['itemType'] + ' ' '<b>' + translate['Quantity'] + ':</b> ' + str(item['itemQty']) + ' '
profileStr += \
'<b>' + translate['Type'] + ':</b> ' + item['itemType'] + ' '
profileStr += \ profileStr += \
'<b>' + translate['Category'] + ':</b> ' + item['category'] + ' ' '<b>' + translate['Category'] + ':</b> ' + item['category'] + ' '
profileStr += \ profileStr += \