forked from indymedia/epicyon
Assigning site editors
parent
f2913b47ed
commit
7b616a4c70
61
daemon.py
61
daemon.py
|
@ -105,6 +105,7 @@ from blocking import isBlockedDomain
|
|||
from blocking import getDomainBlocklist
|
||||
from roles import setRole
|
||||
from roles import clearModeratorStatus
|
||||
from roles import clearEditorStatus
|
||||
from blog import htmlBlogPageRSS2
|
||||
from blog import htmlBlogPageRSS3
|
||||
from blog import htmlBlogView
|
||||
|
@ -3558,6 +3559,66 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'instance',
|
||||
'moderator')
|
||||
|
||||
# change site editors list
|
||||
if fields.get('editors'):
|
||||
adminNickname = \
|
||||
getConfigParam(baseDir, 'admin')
|
||||
if adminNickname:
|
||||
if path.startswith('/users/' +
|
||||
adminNickname + '/'):
|
||||
editorsFile = \
|
||||
baseDir + \
|
||||
'/accounts/editors.txt'
|
||||
clearEditorStatus(baseDir)
|
||||
if ',' in fields['editors']:
|
||||
# if the list was given as comma separated
|
||||
edFile = open(editorsFile, "w+")
|
||||
eds = fields['editors'].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['editors'].split(',')
|
||||
for edNick in eds:
|
||||
edNick = edNick.strip()
|
||||
edDir = baseDir + \
|
||||
'/accounts/' + edNick + \
|
||||
'@' + domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(baseDir,
|
||||
edNick, domain,
|
||||
'instance', 'editor')
|
||||
else:
|
||||
# nicknames on separate lines
|
||||
edFile = open(editorsFile, "w+")
|
||||
eds = fields['editors'].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['editors'].split('\n')
|
||||
for edNick in eds:
|
||||
edNick = edNick.strip()
|
||||
edDir = \
|
||||
baseDir + \
|
||||
'/accounts/' + \
|
||||
edNick + '@' + \
|
||||
domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(baseDir,
|
||||
edNick, domain,
|
||||
'instance',
|
||||
'editor')
|
||||
|
||||
# remove scheduled posts
|
||||
if fields.get('removeScheduledPosts'):
|
||||
if fields['removeScheduledPosts'] == 'on':
|
||||
|
|
20
roles.py
20
roles.py
|
@ -37,6 +37,26 @@ def clearModeratorStatus(baseDir: str) -> None:
|
|||
saveJson(actorJson, filename)
|
||||
|
||||
|
||||
def clearEditorStatus(baseDir: str) -> None:
|
||||
"""Removes editor status from all accounts
|
||||
This could be slow if there are many users, but only happens
|
||||
rarely when editors are appointed or removed
|
||||
"""
|
||||
directory = os.fsencode(baseDir + '/accounts/')
|
||||
for f in os.scandir(directory):
|
||||
f = f.name
|
||||
filename = os.fsdecode(f)
|
||||
if filename.endswith(".json") and '@' in filename:
|
||||
filename = os.path.join(baseDir + '/accounts/', filename)
|
||||
if '"editor"' in open(filename).read():
|
||||
actorJson = loadJson(filename)
|
||||
if actorJson:
|
||||
if actorJson['roles'].get('instance'):
|
||||
if 'editor' in actorJson['roles']['instance']:
|
||||
actorJson['roles']['instance'].remove('editor')
|
||||
saveJson(actorJson, filename)
|
||||
|
||||
|
||||
def addModerator(baseDir: str, nickname: str, domain: str) -> None:
|
||||
"""Adds a moderator nickname to the file
|
||||
"""
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "هذا مثال أخبار",
|
||||
"News": "أخبار",
|
||||
"Read more...": "اقرأ أكثر...",
|
||||
"Edit News Post": "تحرير منشور الأخبار"
|
||||
"Edit News Post": "تحرير منشور الأخبار",
|
||||
"A list of editor nicknames. One per line.": "قائمة بأسماء المحرر. واحد في كل سطر.",
|
||||
"Site Editors": "محررو الموقع"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Aquesta és una instància de notícies",
|
||||
"News": "Notícies",
|
||||
"Read more...": "Llegeix més...",
|
||||
"Edit News Post": "Edita la publicació de notícies"
|
||||
"Edit News Post": "Edita la publicació de notícies",
|
||||
"A list of editor nicknames. One per line.": "Una llista de sobrenoms de l'editor. Un per línia.",
|
||||
"Site Editors": "Editors de llocs"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Dyma enghraifft newyddion",
|
||||
"News": "Newyddion",
|
||||
"Read more...": "Darllen mwy...",
|
||||
"Edit News Post": "Golygu News News"
|
||||
"Edit News Post": "Golygu News News",
|
||||
"A list of editor nicknames. One per line.": "Rhestr o lysenwau golygydd. Un i bob llinell.",
|
||||
"Site Editors": "Golygyddion Safle"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Dies ist eine Nachrichteninstanz",
|
||||
"News": "Nachrichten",
|
||||
"Read more...": "Weiterlesen...",
|
||||
"Edit News Post": "Nachrichtenbeitrag bearbeiten"
|
||||
"Edit News Post": "Nachrichtenbeitrag bearbeiten",
|
||||
"A list of editor nicknames. One per line.": "Eine Liste der Editor-Spitznamen. Eine pro Zeile.",
|
||||
"Site Editors": "Site-Editoren"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "This is a news instance",
|
||||
"News": "News",
|
||||
"Read more...": "Read more...",
|
||||
"Edit News Post": "Edit News Post"
|
||||
"Edit News Post": "Edit News Post",
|
||||
"A list of editor nicknames. One per line.": "A list of editor nicknames. One per line.",
|
||||
"Site Editors": "Site Editors"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Esta es una instancia de noticias",
|
||||
"News": "Noticias",
|
||||
"Read more...": "Lee mas...",
|
||||
"Edit News Post": "Editar publicación de noticias"
|
||||
"Edit News Post": "Editar publicación de noticias",
|
||||
"A list of editor nicknames. One per line.": "Una lista de apodos de los editores. Uno por línea.",
|
||||
"Site Editors": "Editores del sitio"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Ceci est une instance d'actualité",
|
||||
"News": "Nouvelles",
|
||||
"Read more...": "Lire la suite...",
|
||||
"Edit News Post": "Modifier l'article d'actualité"
|
||||
"Edit News Post": "Modifier l'article d'actualité",
|
||||
"A list of editor nicknames. One per line.": "Une liste de surnoms d'éditeur. Un par ligne.",
|
||||
"Site Editors": "Éditeurs du site"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Is sampla nuachta é seo",
|
||||
"News": "Nuacht",
|
||||
"Read more...": "Leigh Nios mo...",
|
||||
"Edit News Post": "Cuir News Post in eagar"
|
||||
"Edit News Post": "Cuir News Post in eagar",
|
||||
"A list of editor nicknames. One per line.": "Liosta leasainmneacha eagarthóra. Ceann in aghaidh na líne.",
|
||||
"Site Editors": "Eagarthóirí Suímh"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "यह एक समाचार का उदाहरण है",
|
||||
"News": "समाचार",
|
||||
"Read more...": "अधिक पढ़ें...",
|
||||
"Edit News Post": "समाचार पोस्ट संपादित करें"
|
||||
"Edit News Post": "समाचार पोस्ट संपादित करें",
|
||||
"A list of editor nicknames. One per line.": "संपादक उपनामों की एक सूची। प्रति पंक्ति एक।",
|
||||
"Site Editors": "साइट संपादकों"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Questa è un'istanza di notizie",
|
||||
"News": "Notizia",
|
||||
"Read more...": "Leggi di più...",
|
||||
"Edit News Post": "Modifica post di notizie"
|
||||
"Edit News Post": "Modifica post di notizie",
|
||||
"A list of editor nicknames. One per line.": "Un elenco di soprannomi dell'editor. Uno per riga.",
|
||||
"Site Editors": "Editori del sito"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "これはニュースインスタンスです",
|
||||
"News": "ニュース",
|
||||
"Read more...": "続きを読む...",
|
||||
"Edit News Post": "ニュース投稿を編集する"
|
||||
"Edit News Post": "ニュース投稿を編集する",
|
||||
"A list of editor nicknames. One per line.": "編集者のニックネームのリスト。 1行に1つ。",
|
||||
"Site Editors": "サイト編集者"
|
||||
}
|
||||
|
|
|
@ -302,5 +302,7 @@
|
|||
"This is a news instance": "This is a news instance",
|
||||
"News": "News",
|
||||
"Read more...": "Read more...",
|
||||
"Edit News Post": "Edit News Post"
|
||||
"Edit News Post": "Edit News Post",
|
||||
"A list of editor nicknames. One per line.": "A list of editor nicknames. One per line.",
|
||||
"Site Editors": "Site Editors"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Esta é uma instância de notícias",
|
||||
"News": "Notícia",
|
||||
"Read more...": "Consulte Mais informação...",
|
||||
"Edit News Post": "Editar Postagem de Notícias"
|
||||
"Edit News Post": "Editar Postagem de Notícias",
|
||||
"A list of editor nicknames. One per line.": "Uma lista de apelidos de editores. Um por linha.",
|
||||
"Site Editors": "Editores do site"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "Это новостной экземпляр",
|
||||
"News": "Новости",
|
||||
"Read more...": "Подробнее...",
|
||||
"Edit News Post": "Редактировать новость"
|
||||
"Edit News Post": "Редактировать новость",
|
||||
"A list of editor nicknames. One per line.": "Список ников редакторов. По одному на строку.",
|
||||
"Site Editors": "Редакторы сайта"
|
||||
}
|
||||
|
|
|
@ -306,5 +306,7 @@
|
|||
"This is a news instance": "这是一个新闻实例",
|
||||
"News": "新闻",
|
||||
"Read more...": "阅读更多...",
|
||||
"Edit News Post": "编辑新闻帖子"
|
||||
"Edit News Post": "编辑新闻帖子",
|
||||
"A list of editor nicknames. One per line.": "编辑者昵称列表。 每行一个。",
|
||||
"Site Editors": "网站编辑"
|
||||
}
|
||||
|
|
|
@ -1698,6 +1698,20 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
|
|||
'..." style="height:200px">' + moderators + '</textarea>'
|
||||
moderatorsStr += '</div>'
|
||||
|
||||
editors = ''
|
||||
editorsFile = baseDir + '/accounts/editors.txt'
|
||||
if os.path.isfile(editorsFile):
|
||||
with open(editorsFile, "r") as f:
|
||||
editors = f.read()
|
||||
editorsStr = '<div class="container">'
|
||||
editorsStr += ' <b>' + translate['Site Editors'] + '</b><br>'
|
||||
editorsStr += ' ' + \
|
||||
translate['A list of editor nicknames. One per line.']
|
||||
editorsStr += \
|
||||
' <textarea id="message" name="editors" placeholder="" ' + \
|
||||
'style="height:200px">' + editors + '</textarea>'
|
||||
editorsStr += '</div>'
|
||||
|
||||
themes = getThemesList()
|
||||
themesDropdown = '<div class="container">'
|
||||
themesDropdown += ' <b>' + translate['Theme'] + '</b><br>'
|
||||
|
|
Loading…
Reference in New Issue