Counselor role

merge-requests/30/head
Bob Mottram 2021-03-08 23:03:02 +00:00
parent 6c374efdb5
commit 863f9ff6c0
19 changed files with 130 additions and 17 deletions

View File

@ -120,6 +120,7 @@ from blocking import getDomainBlocklist
from roles import setRole
from roles import clearModeratorStatus
from roles import clearEditorStatus
from roles import clearCounselorStatus
from blog import htmlBlogPageRSS2
from blog import htmlBlogPageRSS3
from blog import htmlBlogView
@ -4728,6 +4729,63 @@ class PubServer(BaseHTTPRequestHandler):
'instance',
'editor')
# change site counselors list
if fields.get('counselors'):
if path.startswith('/users/' +
adminNickname + '/'):
counselorsFile = \
baseDir + \
'/accounts/counselors.txt'
clearCounselorStatus(baseDir)
if ',' in fields['counselors']:
# if the list was given as comma separated
edFile = open(counselorsFile, "w+")
eds = fields['counselors'].split(',')
for edNick in eds:
edNick = edNick.strip()
edDir = baseDir + \
'/accounts/' + edNick + \
'@' + domain
if os.path.isdir(edDir):
edFile.write(edNick + '\n')
edFile.close()
eds = fields['counselors'].split(',')
for edNick in eds:
edNick = edNick.strip()
edDir = baseDir + \
'/accounts/' + edNick + \
'@' + domain
if os.path.isdir(edDir):
setRole(baseDir,
edNick, domain,
'instance', 'counselor')
else:
# nicknames on separate lines
edFile = open(counselorsFile, "w+")
eds = fields['counselors'].split('\n')
for edNick in eds:
edNick = edNick.strip()
edDir = \
baseDir + \
'/accounts/' + edNick + \
'@' + domain
if os.path.isdir(edDir):
edFile.write(edNick + '\n')
edFile.close()
eds = fields['counselors'].split('\n')
for edNick in eds:
edNick = edNick.strip()
edDir = \
baseDir + \
'/accounts/' + \
edNick + '@' + \
domain
if os.path.isdir(edDir):
setRole(baseDir,
edNick, domain,
'instance',
'counselor')
# remove scheduled posts
if fields.get('removeScheduledPosts'):
if fields['removeScheduledPosts'] == 'on':

View File

@ -51,6 +51,14 @@ def clearEditorStatus(baseDir: str) -> None:
_clearRoleStatus(baseDir, 'editor')
def clearCounselorStatus(baseDir: str) -> None:
"""Removes counselor status from all accounts
This could be slow if there are many users, but only happens
rarely when counselors are appointed or removed
"""
_clearRoleStatus(baseDir, 'editor')
def clearModeratorStatus(baseDir: str) -> None:
"""Removes moderator status from all accounts
This could be slow if there are many users, but only happens
@ -119,7 +127,8 @@ def setRole(baseDir: str, nickname: str, domain: str,
roleFiles = {
"moderator": "moderators.txt",
"editor": "editors.txt"
"editor": "editors.txt",
"counselor": "counselors.txt"
}
actorJson = loadJson(actorFilename)

View File

@ -397,5 +397,7 @@
"Role Assignment": "تعيين الدور",
"Contact Details": "بيانات المتصل",
"Background Images": "صور الخلفية",
"heart": "قلب"
"heart": "قلب",
"counselor": "مستشار",
"Counselors": "المستشارين"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Assignació de funcions",
"Contact Details": "Detalls de contacte",
"Background Images": "Imatges de fons",
"heart": "cor"
"heart": "cor",
"counselor": "conseller",
"Counselors": "Consellers"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Aseiniad Rôl",
"Background Images": "Delweddau Cefndir",
"Contact Details": "Manylion cyswllt",
"heart": "galon"
"heart": "galon",
"counselor": "cynghorydd",
"Counselors": "Cynghorwyr"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Rollenzuweisung",
"Background Images": "Hintergrundbilder",
"Contact Details": "Kontaktdetails",
"heart": "herz"
"heart": "herz",
"counselor": "Beraterin",
"Counselors": "Berater"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Role Assignment",
"Contact Details": "Contact Details",
"Background Images": "Background Images",
"heart": "heart"
"heart": "heart",
"counselor": "counselor",
"Counselors": "Counselors"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Asignación de roles",
"Background Images": "Imágenes de fondo",
"Contact Details": "Detalles de contacto",
"heart": "corazón"
"heart": "corazón",
"counselor": "Consejera",
"Counselors": "Consejeras"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Attribution de rôle",
"Background Images": "Images d'arrière-plan",
"Contact Details": "Détails du contact",
"heart": "cœur"
"heart": "cœur",
"counselor": "Conseillère",
"Counselors": "Conseillères"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Sannadh Róil",
"Background Images": "Íomhánna Cúlra",
"Contact Details": "Sonraí Teagmhála",
"heart": "chroí"
"heart": "chroí",
"counselor": "Comhairleoir",
"Counselors": "Comhairleoirí"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "भूमिका असाइनमेंट",
"Background Images": "पृष्ठभूमि छवियों",
"Contact Details": "सम्पर्क करने का विवरण",
"heart": "दिल"
"heart": "दिल",
"counselor": "काउंसलर",
"Counselors": "सलाहकार"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Assegnazione del ruolo",
"Background Images": "Immagini di sfondo",
"Contact Details": "Dettagli del contatto",
"heart": "cuore"
"heart": "cuore",
"counselor": "Consulente",
"Counselors": "Consiglieri"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "役割の割り当て",
"Background Images": "背景画像",
"Contact Details": "連絡先の詳細",
"heart": "ハート"
"heart": "ハート",
"counselor": "カウンセラー",
"Counselors": "カウンセラー"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Erk Rol",
"Contact Details": "Agahdariyên Têkiliyê",
"Background Images": "Wêneyên Paşê",
"heart": "dil"
"heart": "dil",
"counselor": "Pêşnîyarvan",
"Counselors": "Selêwirmendan"
}

View File

@ -393,5 +393,7 @@
"Role Assignment": "Role Assignment",
"Background Images": "Background Images",
"Contact Details": "Contact Details",
"heart": "heart"
"heart": "heart",
"counselor": "Counselors",
"Counselors": "Counselors"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Atribuição de Função",
"Background Images": "Imagens de fundo",
"Contact Details": "Detalhes do contato",
"heart": "coração"
"heart": "coração",
"counselor": "Conselheira",
"Counselors": "Conselheiras"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "Назначение ролей",
"Background Images": "Фоновые изображения",
"Contact Details": "Контактная информация",
"heart": "сердце"
"heart": "сердце",
"counselor": "Советник",
"Counselors": "Советники"
}

View File

@ -397,5 +397,7 @@
"Role Assignment": "角色分配",
"Background Images": "背景图片",
"Contact Details": "联系方式",
"heart": "心"
"heart": "心",
"counselor": "顾问",
"Counselors": "辅导员"
}

View File

@ -1387,6 +1387,20 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
' <textarea id="message" name="editors" placeholder="" ' + \
'style="height:200px" spellcheck="false">' + \
editors + '</textarea>'
# counselors
counselors = ''
counselorsFile = baseDir + '/accounts/counselors.txt'
if os.path.isfile(counselorsFile):
with open(counselorsFile, "r") as f:
counselors = f.read()
roleAssignStr += ' <b><label class="labels">' + \
translate['Counselors'] + '</label></b><br>\n'
roleAssignStr += \
' <textarea id="message" name="counselors" ' + \
'placeholder="" ' + \
'style="height:200px" spellcheck="false">' + \
counselors + '</textarea>'
roleAssignStr += ' </div></details>\n'
# Video section