diff --git a/webapp_search.py b/webapp_search.py index 31d03f1af..3b2c808df 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -156,13 +156,14 @@ def _htmlSearchResultSharePage(actor: str, domainFull: str, return sharedItemsForm -def _htmlSharesResult(sharesJson: {}, pageNumber: int, resultsPerPage: int, +def _htmlSharesResult(baseDir: str, + sharesJson: {}, pageNumber: int, resultsPerPage: int, searchStrLowerList: [], currPage: int, ctr: int, callingDomain: str, httpPrefix: str, domainFull: str, contactNickname: str, actor: str, resultsExist: bool, searchStrLower: str, translate: {}) -> (bool, int, int, str): - """ + """Result for shared items search """ sharedItemsForm = '' if currPage > pageNumber: @@ -173,7 +174,7 @@ def _htmlSharesResult(sharesJson: {}, pageNumber: int, resultsPerPage: int, if currPage == pageNumber: # show individual search result sharedItemsForm += \ - htmlSearchResultShare(sharedItem, translate, + htmlSearchResultShare(baseDir, sharedItem, translate, httpPrefix, domainFull, contactNickname, name, actor) @@ -247,7 +248,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {}, continue (resultsExist, currPage, ctr, - resultStr) = _htmlSharesResult(sharesJson, pageNumber, + resultStr) = _htmlSharesResult(baseDir, sharesJson, pageNumber, resultsPerPage, searchStrLowerList, currPage, ctr, @@ -280,7 +281,8 @@ def htmlSearchSharedItems(cssCache: {}, translate: {}, continue (resultsExist, currPage, ctr, - resultStr) = _htmlSharesResult(sharesJson, pageNumber, + resultStr) = _htmlSharesResult(baseDir, sharesJson, + pageNumber, resultsPerPage, searchStrLowerList, currPage, ctr, diff --git a/webapp_utils.py b/webapp_utils.py index 49c2970d3..c7c360f61 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -24,6 +24,7 @@ from cache import storePersonInCache from content import addHtmlTags from content import replaceEmojiFromTags from person import getPersonAvatarUrl +from posts import isModerator def getBrokenLinkSubstitute() -> str: @@ -1253,7 +1254,7 @@ def editTextArea(label: str, name: str, value: str = "", return text -def htmlSearchResultShare(sharedItem: {}, translate: {}, +def htmlSearchResultShare(baseDir: str, sharedItem: {}, translate: {}, httpPrefix: str, domainFull: str, contactNickname: str, name: str, actor: str) -> str: @@ -1298,7 +1299,21 @@ def htmlSearchResultShare(sharedItem: {}, translate: {}, '

\n' + + # should the remove button be shown? + showRemoveButton = False + nickname = getNicknameFromActor(actor) if actor.endswith('/users/' + contactNickname): + showRemoveButton = True + elif isModerator(baseDir, nickname): + showRemoveButton = True + else: + adminNickname = getConfigParam(baseDir, 'admin') + if adminNickname: + if actor.endswith('/users/' + adminNickname): + showRemoveButton = True + + if showRemoveButton: sharedItemsForm += \ '