Moderator information screen

master
Bob Mottram 2019-08-13 18:25:39 +01:00
parent b410de1a7b
commit a44cabb849
2 changed files with 43 additions and 10 deletions

View File

@ -90,6 +90,7 @@ from webinterface import htmlProfileAfterSearch
from webinterface import htmlEditProfile from webinterface import htmlEditProfile
from webinterface import htmlTermsOfService from webinterface import htmlTermsOfService
from webinterface import htmlHashtagSearch from webinterface import htmlHashtagSearch
from webinterface import htmlModerationInfo
from shares import getSharesFeedForPerson from shares import getSharesFeedForPerson
from shares import outboxShareUpload from shares import outboxShareUpload
from shares import outboxUndoShareUpload from shares import outboxUndoShareUpload
@ -2118,6 +2119,11 @@ class PubServer(BaseHTTPRequestHandler):
if '=' in moderationStr: if '=' in moderationStr:
moderationText=moderationStr.split('=')[1].strip() moderationText=moderationStr.split('=')[1].strip()
moderationText=moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip() moderationText=moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
elif moderationStr.startswith('submitInfo'):
self._login_headers('text/html')
self.wfile.write(htmlModerationInfo(self.server.baseDir).encode('utf-8'))
self.server.POSTbusy=False
return
elif moderationStr.startswith('submitBlock'): elif moderationStr.startswith('submitBlock'):
moderationButton='block' moderationButton='block'
elif moderationStr.startswith('submitUnblock'): elif moderationStr.startswith('submitUnblock'):

View File

@ -35,16 +35,42 @@ from content import getMentionsFromHtml
from config import getConfigParam from config import getConfigParam
from skills import getSkills from skills import getSkills
def noOfModerationPosts(baseDir: str) -> int: def htmlModerationInfo(baseDir: str) -> str:
"""Returns the number of posts addressed to moderators infoForm=''
""" with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
moderationIndexFile=baseDir+'/accounts/moderation.txt' infoCSS=cssFile.read()
if not os.path.isfile(moderationIndexFile): infoForm=htmlHeader(infoCSS)
return 0
with open(moderationIndexFile, "r") as f: infoForm+='<center><h1>Moderation Information</h1></center>'
lines = f.readlines()
return len(lines) infoShown=False
return 0 suspendedFilename=baseDir+'/accounts/suspended.txt'
if os.path.isfile(suspendedFilename):
with open(suspendedFilename, "r") as f:
suspendedStr = f.read()
infoForm+= \
'<div class="container">' \
' <br><b>Suspended accounts</b>' \
' <br>These are currently suspended' \
' <textarea id="message" name="suspended" style="height:200px">'+suspendedStr+'</textarea>' \
'</div>'
infoShown=True
blockingFilename=baseDir+'/accounts/blocking.txt'
if os.path.isfile(blockingFilename):
with open(blockingFilename, "r") as f:
blockedStr = f.read()
infoForm+= \
'<div class="container">' \
' <br><b>Blocked accounts</b>' \
' <br>These are globally blocked for all accounts on this instance' \
' <textarea id="message" name="blocked" style="height:200px">'+blockedStr+'</textarea>' \
'</div>'
infoShown=True
if not infoShown:
infoForm+='<center><p>Any blocks or suspensions made by moderators will be shown here.</p></center>'
infoForm+=htmlFooter()
return infoForm
def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: int, def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: int,
session,wfRequest: {},personCache: {}) -> str: session,wfRequest: {},personCache: {}) -> str:
@ -1075,6 +1101,7 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
' <input type="submit" title="Remove a suspension for an account nickname" name="submitUnsuspend" value="Unsuspend">' \ ' <input type="submit" title="Remove a suspension for an account nickname" name="submitUnsuspend" value="Unsuspend">' \
' <input type="submit" title="Block an account on another instance" name="submitBlock" value="Block">' \ ' <input type="submit" title="Block an account on another instance" name="submitBlock" value="Block">' \
' <input type="submit" title="Unblock an account on another instance" name="submitUnblock" value="Unblock">' \ ' <input type="submit" title="Unblock an account on another instance" name="submitUnblock" value="Unblock">' \
' <input type="submit" title="Information about current blocks/suspensions" name="submitInfo" value="Info">' \
'</div></form>' '</div></form>'
# add the javascript for content warnings # add the javascript for content warnings