From 48aff7b61e2e8248aae53fb60d0994ae03a94ea5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 14 Oct 2020 10:35:14 +0100 Subject: [PATCH] Moderators can change newswire posting permission from person options --- daemon.py | 30 +++++++++++++++++++++++++++++- posts.py | 5 +++-- translations/ar.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/zh.json | 3 ++- webinterface.py | 44 +++++++++++++++++++++++++++++--------------- 18 files changed, 91 insertions(+), 33 deletions(-) diff --git a/daemon.py b/daemon.py index 066302632..1d3327b1d 100644 --- a/daemon.py +++ b/daemon.py @@ -1688,7 +1688,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.POSTbusy = False return - # person on calendar checkbox on person option screen + # person options screen, on calendar checkbox + # See htmlPersonOptions if '&submitOnCalendar=' in optionsConfirmParams: onCalendar = None if 'onCalendar=' in optionsConfirmParams: @@ -1714,6 +1715,32 @@ class PubServer(BaseHTTPRequestHandler): self.server.POSTbusy = False return + # person options screen, permission to post to newswire + # See htmlPersonOptions + if '&submitPostToNews=' in optionsConfirmParams: + postsToNews = None + if 'postsToNews=' in optionsConfirmParams: + postsToNews = optionsConfirmParams.split('postsToNews=')[1] + if '&' in postsToNews: + postsToNews = postsToNews.split('&')[0] + newswireBlockedFilename = \ + self.server.baseDir + '/accounts/' + \ + optionsNickname + '@' + optionsDomain + '/.nonewswire' + if postsToNews == 'on': + if os.path.isfile(newswireBlockedFilename): + os.remove(newswireBlockedFilename) + else: + noNewswireFile = open(newswireBlockedFilename, "w+") + if noNewswireFile: + noNewswireFile.write('\n') + noNewswireFile.close() + self._redirect_headers(usersPath + '/' + + self.server.defaultTimeline + + '?page='+str(pageNumber), cookie, + callingDomain) + self.server.POSTbusy = False + return + # block person button on person option screen if '&submitBlock=' in optionsConfirmParams: if debug: @@ -4446,6 +4473,7 @@ class PubServer(BaseHTTPRequestHandler): PGPfingerprint = getPGPfingerprint(actorJson) msg = htmlPersonOptions(self.server.translate, baseDir, domain, + domainFull, originPathStr, optionsActor, optionsProfileUrl, diff --git a/posts.py b/posts.py index fa3a4a3c3..cd85388d5 100644 --- a/posts.py +++ b/posts.py @@ -3531,8 +3531,9 @@ def rejectAnnounce(announceFilename: str): """ if not os.path.isfile(announceFilename + '.reject'): rejectAnnounceFile = open(announceFilename + '.reject', "w+") - rejectAnnounceFile.write('\n') - rejectAnnounceFile.close() + if rejectAnnounceFile: + rejectAnnounceFile.write('\n') + rejectAnnounceFile.close() def downloadAnnounce(session, baseDir: str, httpPrefix: str, diff --git a/translations/ar.json b/translations/ar.json index ca37a9949..6d6e1ca22 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -308,5 +308,6 @@ "Read more...": "اقرأ أكثر...", "Edit News Post": "تحرير منشور الأخبار", "A list of editor nicknames. One per line.": "قائمة بأسماء المحرر. واحد في كل سطر.", - "Site Editors": "محررو الموقع" + "Site Editors": "محررو الموقع", + "Allow news posts": "السماح بنشر الأخبار" } diff --git a/translations/ca.json b/translations/ca.json index 78a90aff9..33a3ee798 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -308,5 +308,6 @@ "Read more...": "Llegeix més...", "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" + "Site Editors": "Editors de llocs", + "Allow news posts": "Permet publicacions de notícies" } diff --git a/translations/cy.json b/translations/cy.json index a68b2456f..d3ff8d095 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -308,5 +308,6 @@ "Read more...": "Darllen mwy...", "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" + "Site Editors": "Golygyddion Safle", + "Allow news posts": "Caniatáu swyddi newyddion" } diff --git a/translations/de.json b/translations/de.json index 06bdd7e98..1129a9d11 100644 --- a/translations/de.json +++ b/translations/de.json @@ -308,5 +308,6 @@ "Read more...": "Weiterlesen...", "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" + "Site Editors": "Site-Editoren", + "Allow news posts": "Nachrichtenbeiträge zulassen" } diff --git a/translations/en.json b/translations/en.json index 9a10f674f..de4893bab 100644 --- a/translations/en.json +++ b/translations/en.json @@ -308,5 +308,6 @@ "Read more...": "Read more...", "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" + "Site Editors": "Site Editors", + "Allow news posts": "Allow news posts" } diff --git a/translations/es.json b/translations/es.json index 6970b49bd..f8c4d3576 100644 --- a/translations/es.json +++ b/translations/es.json @@ -308,5 +308,6 @@ "Read more...": "Lee mas...", "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" + "Site Editors": "Editores del sitio", + "Allow news posts": "Permitir publicaciones de noticias" } diff --git a/translations/fr.json b/translations/fr.json index 65d770121..f9fdf312f 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -308,5 +308,6 @@ "Read more...": "Lire la suite...", "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" + "Site Editors": "Éditeurs du site", + "Allow news posts": "Autoriser les articles d'actualité" } diff --git a/translations/ga.json b/translations/ga.json index d97ad2671..56d3d52b8 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -308,5 +308,6 @@ "Read more...": "Leigh Nios mo...", "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" + "Site Editors": "Eagarthóirí Suímh", + "Allow news posts": "Ceadaigh poist nuachta" } diff --git a/translations/hi.json b/translations/hi.json index f1ed564bb..900ca3a0f 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -308,5 +308,6 @@ "Read more...": "अधिक पढ़ें...", "Edit News Post": "समाचार पोस्ट संपादित करें", "A list of editor nicknames. One per line.": "संपादक उपनामों की एक सूची। प्रति पंक्ति एक।", - "Site Editors": "साइट संपादकों" + "Site Editors": "साइट संपादकों", + "Allow news posts": "समाचार पोस्ट की अनुमति दें" } diff --git a/translations/it.json b/translations/it.json index d01e1fd46..7ca28454c 100644 --- a/translations/it.json +++ b/translations/it.json @@ -308,5 +308,6 @@ "Read more...": "Leggi di più...", "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" + "Site Editors": "Editori del sito", + "Allow news posts": "Consenti post di notizie" } diff --git a/translations/ja.json b/translations/ja.json index 1867a618d..499ae2cb4 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -308,5 +308,6 @@ "Read more...": "続きを読む...", "Edit News Post": "ニュース投稿を編集する", "A list of editor nicknames. One per line.": "編集者のニックネームのリスト。 1行に1つ。", - "Site Editors": "サイト編集者" + "Site Editors": "サイト編集者", + "Allow news posts": "ニュース投稿を許可する" } diff --git a/translations/oc.json b/translations/oc.json index 5f54ec75d..9f2745a36 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -304,5 +304,6 @@ "Read more...": "Read more...", "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" + "Site Editors": "Site Editors", + "Allow news posts": "Allow news posts" } diff --git a/translations/pt.json b/translations/pt.json index 78832177e..096432607 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -308,5 +308,6 @@ "Read more...": "Consulte Mais informação...", "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" + "Site Editors": "Editores do site", + "Allow news posts": "Permitir postagens de notícias" } diff --git a/translations/ru.json b/translations/ru.json index 798d51b18..a9d7e7a89 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -308,5 +308,6 @@ "Read more...": "Подробнее...", "Edit News Post": "Редактировать новость", "A list of editor nicknames. One per line.": "Список ников редакторов. По одному на строку.", - "Site Editors": "Редакторы сайта" + "Site Editors": "Редакторы сайта", + "Allow news posts": "Разрешить публикации новостей" } diff --git a/translations/zh.json b/translations/zh.json index ffd2dd28c..7e6297e43 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -308,5 +308,6 @@ "Read more...": "阅读更多...", "Edit News Post": "编辑新闻帖子", "A list of editor nicknames. One per line.": "编辑者昵称列表。 每行一个。", - "Site Editors": "网站编辑" + "Site Editors": "网站编辑", + "Allow news posts": "允许新闻发布" } diff --git a/webinterface.py b/webinterface.py index bb3b7c4b7..5891dda38 100644 --- a/webinterface.py +++ b/webinterface.py @@ -7275,7 +7275,8 @@ def htmlUnfollowConfirm(translate: {}, baseDir: str, def htmlPersonOptions(translate: {}, baseDir: str, - domain: str, originPathStr: str, + domain: str, domainFull: str, + originPathStr: str, optionsActor: str, optionsProfileUrl: str, optionsLink: str, @@ -7413,24 +7414,37 @@ def htmlPersonOptions(translate: {}, baseDir: str, 'name="submitPetname">' + \ translate['Submit'] + '
\n' + # checkbox for receiving calendar events if isFollowingActor(baseDir, nickname, domain, optionsActor): - if receivingCalendarEvents(baseDir, nickname, domain, - optionsNickname, optionsDomainFull): - optionsStr += \ + 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 + if optionsDomainFull == domainFull: + if isModerator(baseDir, nickname) and \ + not isModerator(baseDir, optionsNickname): + newswireBlockedFilename = \ + baseDir + '/accounts/' + \ + optionsNickname + '@' + optionsDomain + '/.nonewswire' + checkboxStr = \ ' ' + \ - translate['Receive calendar events from this account'] + \ + 'class="profilecheckbox" name="postsToNews" checked> ' + \ + translate['Allow news posts'] + \ '\n
\n' - else: - optionsStr += \ - ' ' + \ - translate['Receive calendar events from this account'] + \ - '\n
\n' + if os.path.isfile(newswireBlockedFilename): + checkboxStr = checkboxStr.replace(' checked>', '>') + optionsStr += checkboxStr optionsStr += optionsLinkStr optionsStr += \