diff --git a/daemon.py b/daemon.py index d2029b346..b147c100d 100644 --- a/daemon.py +++ b/daemon.py @@ -2819,7 +2819,7 @@ class PubServer(BaseHTTPRequestHandler): domain, domainFull, GETstartTime, GETtimings, onionDomain, i2pDomain, - cookie, debug) + cookie, debug, authorized) return else: showPublishedDateOnly = self.server.showPublishedDateOnly @@ -5486,7 +5486,8 @@ class PubServer(BaseHTTPRequestHandler): domain: str, domainFull: str, GETstartTime, GETtimings: {}, onionDomain: str, i2pDomain: str, - cookie: str, debug: bool) -> None: + cookie: str, debug: bool, + authorized: bool) -> None: """Show person options screen """ backToPath = '' @@ -5576,7 +5577,8 @@ class PubServer(BaseHTTPRequestHandler): lockedAccount, movedTo, alsoKnownAs, self.server.textModeBanner, - self.server.newsInstance).encode('utf-8') + self.server.newsInstance, + authorized).encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, cookie, callingDomain) @@ -10495,7 +10497,8 @@ class PubServer(BaseHTTPRequestHandler): GETstartTime, GETtimings, self.server.onionDomain, self.server.i2pDomain, - cookie, self.server.debug) + cookie, self.server.debug, + authorized) return self._benchmarkGETtimings(GETstartTime, GETtimings, diff --git a/webapp_person_options.py b/webapp_person_options.py index 75dd21045..5c903ce9b 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -53,7 +53,8 @@ def htmlPersonOptions(defaultTimeline: str, movedTo: str, alsoKnownAs: [], textModeBanner: str, - newsInstance: bool) -> str: + newsInstance: bool, + authorized: bool) -> str: """Show options for a person: view/follow/block/report """ optionsDomain, optionsPort = getDomainFromActor(optionsActor) @@ -225,88 +226,91 @@ def htmlPersonOptions(defaultTimeline: str, optionsActor + '">\n' optionsStr += ' \n' - if optionsNickname: - handle = optionsNickname + '@' + optionsDomainFull - petname = getPetName(baseDir, nickname, domain, handle) - optionsStr += \ - ' ' + translate['Petname'] + ': \n' + \ - ' \n' \ - '
\n' + if authorized: + if optionsNickname: + handle = optionsNickname + '@' + optionsDomainFull + petname = getPetName(baseDir, nickname, domain, handle) + optionsStr += \ + ' ' + translate['Petname'] + ': \n' + \ + ' \n' \ + '
\n' - # checkbox for receiving calendar events - if isFollowingActor(baseDir, nickname, domain, optionsActor): - checkboxStr = \ - ' ' + \ - translate['Receive calendar events from this account'] + \ - '\n
\n' - if not receivingCalendarEvents(baseDir, nickname, domain, - optionsNickname, optionsDomainFull): - checkboxStr = checkboxStr.replace(' checked>', '>') - optionsStr += checkboxStr + # checkbox for receiving calendar events + if isFollowingActor(baseDir, nickname, domain, optionsActor): + checkboxStr = \ + ' ' + \ + translate['Receive calendar events from this account'] + \ + '\n
\n' + if not receivingCalendarEvents(baseDir, nickname, domain, + optionsNickname, + optionsDomainFull): + checkboxStr = checkboxStr.replace(' checked>', '>') + optionsStr += checkboxStr - # checkbox for permission to post to newswire - newswirePostsPermitted = False - if optionsDomainFull == domainFull: - adminNickname = getConfigParam(baseDir, 'admin') - if (nickname == adminNickname or - (isModerator(baseDir, nickname) and - not isModerator(baseDir, optionsNickname))): - newswireBlockedFilename = \ + # checkbox for permission to post to newswire + newswirePostsPermitted = False + if optionsDomainFull == domainFull: + adminNickname = getConfigParam(baseDir, 'admin') + if (nickname == adminNickname or + (isModerator(baseDir, nickname) and + not isModerator(baseDir, optionsNickname))): + newswireBlockedFilename = \ + baseDir + '/accounts/' + \ + optionsNickname + '@' + optionsDomain + '/.nonewswire' + checkboxStr = \ + ' ' + \ + translate['Allow news posts'] + \ + '\n
\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/' + \ - optionsNickname + '@' + optionsDomain + '/.nonewswire' + optionsNickname + '@' + optionsDomain + '/.newswiremoderated' checkboxStr = \ ' ' + \ - translate['Allow news posts'] + \ + 'class="profilecheckbox" name="modNewsPosts" checked> ' + \ + translate['News posts are moderated'] + \ '\n
\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/' + \ - optionsNickname + '@' + optionsDomain + '/.newswiremoderated' - checkboxStr = \ - ' ' + \ - translate['News posts are moderated'] + \ - '\n
\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 = \ - ' ' + \ - translate['Featured writer'] + \ - '\n
\n' - if not isFeaturedWriter(baseDir, optionsNickname, - optionsDomain): + 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 = \ + ' ' + \ + translate['Featured writer'] + \ + '\n
\n' + if not isFeaturedWriter(baseDir, optionsNickname, + optionsDomain): + checkboxStr = checkboxStr.replace(' checked>', '>') + optionsStr += checkboxStr + optionsStr += optionsLinkStr backPath = '/' if nickname: @@ -317,49 +321,52 @@ def htmlPersonOptions(defaultTimeline: str, ' \n' - optionsStr += \ - ' \n' + if authorized: + optionsStr += \ + ' \n' optionsStr += donateStr - optionsStr += \ - ' \n' - optionsStr += \ - ' \n' - optionsStr += \ - ' \n' - optionsStr += \ - ' \n' - optionsStr += \ - ' \n' - - if isModerator(baseDir, nickname): + if authorized: + optionsStr += \ + ' \n' + optionsStr += \ + ' \n' + optionsStr += \ + ' \n' + optionsStr += \ + ' \n' optionsStr += \ ' \n' + 'name="submitReport">' + translate['Report'] + '\n' - personNotes = '' - personNotesFilename = \ - baseDir + '/accounts/' + nickname + '@' + domain + \ - '/notes/' + handle + '.txt' - if os.path.isfile(personNotesFilename): - with open(personNotesFilename, 'r') as fp: - personNotes = fp.read() + if isModerator(baseDir, nickname): + optionsStr += \ + ' \n' - optionsStr += \ - '

' + translate['Notes'] + ': \n' - optionsStr += '
\n' - optionsStr += \ - ' \n' + personNotes = '' + personNotesFilename = \ + baseDir + '/accounts/' + nickname + '@' + domain + \ + '/notes/' + handle + '.txt' + if os.path.isfile(personNotesFilename): + with open(personNotesFilename, 'r') as fp: + personNotes = fp.read() + + optionsStr += \ + '

' + translate['Notes'] + ': \n' + optionsStr += '
\n' + optionsStr += \ + ' \n' optionsStr += ' \n' optionsStr += '\n'