mirror of https://gitlab.com/bashrc2/epicyon
Show shared item remove button for admin and moderators
parent
1b2c4cb3e5
commit
b5fc769af3
|
@ -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,
|
||||
|
|
|
@ -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: {},
|
|||
'<p><a href="' + actor + '?replydm=sharedesc:' + \
|
||||
sharedItem['displayName'] + '?mention=' + contactActor + \
|
||||
'"><button class="button">' + translate['Contact'] + '</button></a>\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 += \
|
||||
' <a href="' + actor + '?rmshare=' + \
|
||||
name + '"><button class="button">' + \
|
||||
|
@ -1370,7 +1385,7 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str,
|
|||
'src="/users/' + nickname + '/' + bannerFile + '" /></a>\n' + \
|
||||
'</header><br>\n'
|
||||
shareStr += \
|
||||
htmlSearchResultShare(sharedItem, translate, httpPrefix,
|
||||
htmlSearchResultShare(baseDir, sharedItem, translate, httpPrefix,
|
||||
domainFull, contactNickname, itemID,
|
||||
actor)
|
||||
|
||||
|
|
Loading…
Reference in New Issue