Shared item contact button style

merge-requests/30/head
Bob Mottram 2021-09-21 10:58:55 +01:00
parent 6e386a2e79
commit c2137eca5d
2 changed files with 41 additions and 28 deletions

View File

@ -947,49 +947,59 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
def htmlIndividualShare(domain: str, shareId: str, def htmlIndividualShare(domain: str, shareId: str,
actor: str, item: {}, translate: {}, actor: str, sharedItem: {}, translate: {},
showContact: bool, removeButton: bool, showContact: bool, removeButton: bool,
sharesFileType: str) -> str: sharesFileType: str) -> str:
"""Returns an individual shared item as html """Returns an individual shared item as html
""" """
profileStr = '<div class="container">\n' profileStr = '<div class="container">\n'
profileStr += '<p class="share-title">' + item['displayName'] + '</p>\n'
if item.get('imageUrl'):
profileStr += '<a href="' + item['imageUrl'] + '">\n'
profileStr += \ profileStr += \
'<img loading="lazy" src="' + item['imageUrl'] + \ '<p class="share-title">' + sharedItem['displayName'] + '</p>\n'
if sharedItem.get('imageUrl'):
profileStr += '<a href="' + sharedItem['imageUrl'] + '">\n'
profileStr += \
'<img loading="lazy" src="' + sharedItem['imageUrl'] + \
'" alt="' + translate['Item image'] + '">\n</a>\n' '" alt="' + translate['Item image'] + '">\n</a>\n'
profileStr += '<p>' + item['summary'] + '</p>\n<p>' profileStr += '<p>' + sharedItem['summary'] + '</p>\n<p>'
if item.get('itemQty'): if sharedItem.get('itemQty'):
if item['itemQty'] > 1: if sharedItem['itemQty'] > 1:
profileStr += \ profileStr += \
'<b>' + translate['Quantity'] + ':</b> ' + \ '<b>' + translate['Quantity'] + ':</b> ' + \
str(item['itemQty']) + '<br>' str(sharedItem['itemQty']) + '<br>'
profileStr += \ profileStr += \
'<b>' + translate['Type'] + ':</b> ' + item['itemType'] + '<br>' '<b>' + translate['Type'] + ':</b> ' + sharedItem['itemType'] + '<br>'
profileStr += \ profileStr += \
'<b>' + translate['Category'] + ':</b> ' + item['category'] + '<br>' '<b>' + translate['Category'] + ':</b> ' + \
if item.get('location'): sharedItem['category'] + '<br>'
if sharedItem.get('location'):
profileStr += \ profileStr += \
'<b>' + translate['Location'] + ':</b> ' + \ '<b>' + translate['Location'] + ':</b> ' + \
item['location'] + '<br>' sharedItem['location'] + '<br>'
if item.get('itemPrice') and item.get('itemCurrency'): contactTitleStr = translate['Contact']
if isfloat(item['itemPrice']): if sharedItem.get('itemPrice') and sharedItem.get('itemCurrency'):
if float(item['itemPrice']) > 0: if isfloat(sharedItem['itemPrice']):
if float(sharedItem['itemPrice']) > 0:
profileStr += ' ' + \ profileStr += ' ' + \
'<b>' + translate['Price'] + ':</b> ' + \ '<b>' + translate['Price'] + ':</b> ' + \
item['itemPrice'] + ' ' + item['itemCurrency'] sharedItem['itemPrice'] + ' ' + sharedItem['itemCurrency']
contactTitleStr = translate['Buy']
profileStr += '</p>\n' profileStr += '</p>\n'
sharedesc = item['displayName'] sharedesc = sharedItem['displayName']
if '<' not in sharedesc and ';' not in sharedesc: if '<' not in sharedesc and ';' not in sharedesc:
if showContact: if showContact:
contactActor = item['actor'] buttonStyleStr = 'button'
if sharedItem['category'] == 'accommodation':
contactTitleStr = translate['Request to stay']
buttonStyleStr = 'contactbutton'
contactActor = sharedItem['actor']
profileStr += \ profileStr += \
'<p>' + \ '<p>' + \
'<a href="' + actor + \ '<a href="' + actor + \
'?replydm=sharedesc:' + sharedesc + \ '?replydm=sharedesc:' + sharedesc + \
';mention=' + contactActor + '"><button class="button">' + \ ';mention=' + contactActor + '">' + \
translate['Contact'] + '</button></a>\n' '<button class="' + buttonStyleStr + '">' + \
contactTitleStr + '</button></a>\n'
profileStr += \ profileStr += \
'<a href="' + contactActor + '"><button class="button">' + \ '<a href="' + contactActor + '"><button class="button">' + \
translate['Profile'] + '</button></a>\n' translate['Profile'] + '</button></a>\n'
@ -1049,17 +1059,18 @@ def _htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
if isModerator(baseDir, nickname): if isModerator(baseDir, nickname):
isModeratorAccount = True isModeratorAccount = True
for published, item in sharesJson.items(): for published, sharedItem in sharesJson.items():
showContactButton = False showContactButton = False
if item['actor'] != actor: if sharedItem['actor'] != actor:
showContactButton = True showContactButton = True
showRemoveButton = False showRemoveButton = False
if '___' + domain in item['shareId']: if '___' + domain in sharedItem['shareId']:
if item['actor'] == actor or isAdminAccount or isModeratorAccount: if sharedItem['actor'] == actor or \
isAdminAccount or isModeratorAccount:
showRemoveButton = True showRemoveButton = True
timelineStr += \ timelineStr += \
htmlIndividualShare(domain, item['shareId'], htmlIndividualShare(domain, sharedItem['shareId'],
actor, item, translate, actor, sharedItem, translate,
showContactButton, showRemoveButton, showContactButton, showRemoveButton,
sharesFileType) sharesFileType)
timelineStr += separatorStr timelineStr += separatorStr

View File

@ -1333,15 +1333,17 @@ def htmlSearchResultShare(baseDir: str, sharedItem: {}, translate: {},
sharedItemsForm += '</p>\n' sharedItemsForm += '</p>\n'
contactActor = \ contactActor = \
localActorUrl(httpPrefix, contactNickname, domainFull) localActorUrl(httpPrefix, contactNickname, domainFull)
buttonStyleStr = 'button'
if category == 'accommodation': if category == 'accommodation':
contactTitleStr = translate['Request to stay'] contactTitleStr = translate['Request to stay']
buttonStyleStr = 'contactbutton'
sharedItemsForm += \ sharedItemsForm += \
'<p>' + \ '<p>' + \
'<a href="' + actor + '?replydm=sharedesc:' + \ '<a href="' + actor + '?replydm=sharedesc:' + \
sharedItem['displayName'] + ';mention=' + contactActor + \ sharedItem['displayName'] + ';mention=' + contactActor + \
';category=' + category + \ ';category=' + category + \
'"><button class="contactbutton">' + contactTitleStr + \ '"><button class="' + buttonStyleStr + '">' + contactTitleStr + \
'</button></a>\n' + \ '</button></a>\n' + \
'<a href="' + contactActor + '"><button class="button">' + \ '<a href="' + contactActor + '"><button class="button">' + \
translate['Profile'] + '</button></a>\n' translate['Profile'] + '</button></a>\n'