More checks on visibility of items on person options

merge-requests/30/head
Bob Mottram 2021-02-23 17:51:48 +00:00
parent 2d86165795
commit 9145ac0801
1 changed files with 78 additions and 74 deletions

View File

@ -227,90 +227,94 @@ def htmlPersonOptions(defaultTimeline: str,
optionsStr += ' <input type="hidden" name="avatarUrl" value="' + \ optionsStr += ' <input type="hidden" name="avatarUrl" value="' + \
optionsProfileUrl + '">\n' optionsProfileUrl + '">\n'
if authorized: if authorized:
if optionsNickname: if originPathStr == '/users/' + nickname:
handle = optionsNickname + '@' + optionsDomainFull if optionsNickname:
petname = getPetName(baseDir, nickname, domain, handle) handle = optionsNickname + '@' + optionsDomainFull
optionsStr += \ petname = getPetName(baseDir, nickname, domain, handle)
' ' + translate['Petname'] + ': \n' + \ optionsStr += \
' <input type="text" name="optionpetname" value="' + \ ' ' + translate['Petname'] + ': \n' + \
petname + '">\n' \ ' <input type="text" name="optionpetname" value="' + \
' <button type="submit" class="buttonsmall" ' + \ petname + '">\n' \
'name="submitPetname">' + \ ' <button type="submit" class="buttonsmall" ' + \
translate['Submit'] + '</button><br>\n' 'name="submitPetname">' + \
translate['Submit'] + '</button><br>\n'
# checkbox for receiving calendar events # checkbox for receiving calendar events
if isFollowingActor(baseDir, nickname, domain, optionsActor): if isFollowingActor(baseDir, nickname, domain, optionsActor):
checkboxStr = \ checkboxStr = \
' <input type="checkbox" ' + \ ' <input type="checkbox" ' + \
'class="profilecheckbox" name="onCalendar" checked> ' + \ 'class="profilecheckbox" name="onCalendar" checked> ' + \
translate['Receive calendar events from this account'] + \ translate['Receive calendar events from this account'] + \
'\n <button type="submit" class="buttonsmall" ' + \ '\n <button type="submit" class="buttonsmall" ' + \
'name="submitOnCalendar">' + \ 'name="submitOnCalendar">' + \
translate['Submit'] + '</button><br>\n' translate['Submit'] + '</button><br>\n'
if not receivingCalendarEvents(baseDir, nickname, domain, if not receivingCalendarEvents(baseDir, nickname, domain,
optionsNickname, optionsNickname,
optionsDomainFull): optionsDomainFull):
checkboxStr = checkboxStr.replace(' checked>', '>') checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr optionsStr += checkboxStr
# checkbox for permission to post to newswire # checkbox for permission to post to newswire
newswirePostsPermitted = False newswirePostsPermitted = False
if optionsDomainFull == domainFull: if optionsDomainFull == domainFull:
adminNickname = getConfigParam(baseDir, 'admin') adminNickname = getConfigParam(baseDir, 'admin')
if (nickname == adminNickname or if (nickname == adminNickname or
(isModerator(baseDir, nickname) and (isModerator(baseDir, nickname) and
not isModerator(baseDir, optionsNickname))): not isModerator(baseDir, optionsNickname))):
newswireBlockedFilename = \ newswireBlockedFilename = \
baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.nonewswire'
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" ' + \
'name="postsToNews" checked> ' + \
translate['Allow news posts'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToNews">' + \
translate['Submit'] + '</button><br>\n'
if os.path.isfile(newswireBlockedFilename):
checkboxStr = checkboxStr.replace(' checked>', '>')
else:
newswirePostsPermitted = True
optionsStr += checkboxStr
# whether blogs created by this account are moderated on
# the newswire
if newswirePostsPermitted:
moderatedFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.nonewswire' optionsNickname + '@' + \
optionsDomain + '/.newswiremoderated'
checkboxStr = \ checkboxStr = \
' <input type="checkbox" ' + \ ' <input type="checkbox" ' + \
'class="profilecheckbox" name="postsToNews" checked> ' + \ 'class="profilecheckbox" name="modNewsPosts" checked> ' + \
translate['Allow news posts'] + \ translate['News posts are moderated'] + \
'\n <button type="submit" class="buttonsmall" ' + \ '\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToNews">' + \ 'name="submitModNewsPosts">' + \
translate['Submit'] + '</button><br>\n' translate['Submit'] + '</button><br>\n'
if os.path.isfile(newswireBlockedFilename): if not os.path.isfile(moderatedFilename):
checkboxStr = checkboxStr.replace(' checked>', '>')
else:
newswirePostsPermitted = True
optionsStr += checkboxStr
# whether blogs created by this account are moderated on the newswire
if newswirePostsPermitted:
moderatedFilename = \
baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.newswiremoderated'
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="modNewsPosts" checked> ' + \
translate['News posts are moderated'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitModNewsPosts">' + \
translate['Submit'] + '</button><br>\n'
if not os.path.isfile(moderatedFilename):
checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr
# checkbox for permission to post to featured articles
if newsInstance and optionsDomainFull == domainFull:
adminNickname = getConfigParam(baseDir, 'admin')
if (nickname == adminNickname or
(isModerator(baseDir, nickname) and
not isModerator(baseDir, optionsNickname))):
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" ' + \
'name="postsToFeatures" checked> ' + \
translate['Featured writer'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToFeatures">' + \
translate['Submit'] + '</button><br>\n'
if not isFeaturedWriter(baseDir, optionsNickname,
optionsDomain):
checkboxStr = checkboxStr.replace(' checked>', '>') checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr optionsStr += checkboxStr
# checkbox for permission to post to featured articles
if newsInstance and optionsDomainFull == domainFull:
adminNickname = getConfigParam(baseDir, 'admin')
if (nickname == adminNickname or
(isModerator(baseDir, nickname) and
not isModerator(baseDir, optionsNickname))):
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" ' + \
'name="postsToFeatures" checked> ' + \
translate['Featured writer'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToFeatures">' + \
translate['Submit'] + '</button><br>\n'
if not isFeaturedWriter(baseDir, optionsNickname,
optionsDomain):
checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr
optionsStr += optionsLinkStr optionsStr += optionsLinkStr
backPath = '/' backPath = '/'
if nickname: if nickname: