diff --git a/daemon.py b/daemon.py index 265b5448d..e0e4edca6 100644 --- a/daemon.py +++ b/daemon.py @@ -156,6 +156,7 @@ from roles import get_actor_roles_list from roles import set_role from roles import clear_moderator_status from roles import clear_editor_status +from roles import clear_devops_status from roles import clear_counselor_status from roles import clear_artist_status from blog import path_contains_blog_link @@ -6678,6 +6679,71 @@ class PubServer(BaseHTTPRequestHandler): ed_nick, domain, 'editor') + # change site devops list + if fields.get('devopslist'): + if path.startswith('/users/' + + admin_nickname + '/'): + devops_file = \ + base_dir + \ + '/accounts/devops.txt' + clear_devops_status(base_dir) + if ',' in fields['devopslist']: + # if the list was given as comma separated + dos = fields['devopslist'].split(',') + try: + with open(devops_file, 'w+', + encoding='utf-8') as dofil: + for do_nick in dos: + do_nick = do_nick.strip() + do_dir = base_dir + \ + '/accounts/' + do_nick + \ + '@' + domain + if os.path.isdir(do_dir): + dofil.write(do_nick + '\n') + except OSError as ex: + print('EX: unable to write devops ' + + devops_file + ' ' + str(ex)) + + for do_nick in dos: + do_nick = do_nick.strip() + do_dir = base_dir + \ + '/accounts/' + do_nick + \ + '@' + domain + if os.path.isdir(do_dir): + set_role(base_dir, + do_nick, domain, + 'devops') + else: + # nicknames on separate lines + eds = fields['devopslist'].split('\n') + try: + with open(devops_file, 'w+', + encoding='utf-8') as dofile: + for do_nick in dos: + do_nick = do_nick.strip() + do_dir = \ + base_dir + \ + '/accounts/' + do_nick + \ + '@' + domain + if os.path.isdir(do_dir): + dofile.write(do_nick + + '\n') + except OSError as ex: + print('EX: unable to write devops ' + + devops_file + ' ' + str(ex)) + + for do_nick in dos: + do_nick = do_nick.strip() + do_dir = \ + base_dir + \ + '/accounts/' + \ + do_nick + '@' + \ + domain + if os.path.isdir(do_dir): + set_role(base_dir, + do_nick, domain, + 'devops') + # change site counselors list if fields.get('counselors'): if path.startswith('/users/' + diff --git a/roles.py b/roles.py index b0ab280d1..58ff40647 100644 --- a/roles.py +++ b/roles.py @@ -14,6 +14,7 @@ from utils import get_status_number from utils import remove_domain_port from utils import acct_dir from utils import text_in_file +from utils import get_config_param def _clear_role_status(base_dir: str, role: str) -> None: @@ -49,6 +50,14 @@ def clear_editor_status(base_dir: str) -> None: _clear_role_status(base_dir, 'editor') +def clear_devops_status(base_dir: str) -> None: + """Removes devops status from all accounts + This could be slow if there are many users, but only happens + rarely when devops are appointed or removed + """ + _clear_role_status(base_dir, 'devops') + + def clear_counselor_status(base_dir: str) -> None: """Removes counselor status from all accounts This could be slow if there are many users, but only happens @@ -296,3 +305,32 @@ def actor_has_role(actor_json: {}, role_name: str) -> bool: """ roles_list = get_actor_roles_list(actor_json) return role_name in roles_list + + +def is_devops(base_dir: str, nickname: str) -> bool: + """Returns true if the given nickname has the devops role + """ + devops_file = base_dir + '/accounts/devops.txt' + + if not os.path.isfile(devops_file): + admin_name = get_config_param(base_dir, 'admin') + if not admin_name: + return False + if admin_name == nickname: + return True + return False + + with open(devops_file, 'r', encoding='utf-8') as fp_mod: + lines = fp_mod.readlines() + if len(lines) == 0: + # if there is nothing in the file + admin_name = get_config_param(base_dir, 'admin') + if not admin_name: + return False + if admin_name == nickname: + return True + for devops in lines: + devops = devops.strip('\n').strip('\r') + if devops == nickname: + return True + return False diff --git a/translations/ar.json b/translations/ar.json index 6ff8d37be..39f77aa6c 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -590,5 +590,8 @@ "Last year": "العام الماضي", "Unauthorized": "غير مصرح", "No login credentials were posted": "لم يتم نشر بيانات اعتماد تسجيل الدخول", - "Credentials are too long": "أوراق الاعتماد طويلة جدًا" + "Credentials are too long": "أوراق الاعتماد طويلة جدًا", + "Site DevOps": "DevOps الموقع", + "A list of devops nicknames. One per line.": "قائمة بأسماء المطورين. واحد في كل سطر.", + "devops": "devops" } diff --git a/translations/bn.json b/translations/bn.json index ab0391319..82d5a110f 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -590,5 +590,8 @@ "Last year": "গত বছর", "Unauthorized": "অননুমোদিত", "No login credentials were posted": "কোনো লগইন শংসাপত্র পোস্ট করা হয়নি", - "Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷" + "Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷", + "Site DevOps": "সাইট DevOps", + "A list of devops nicknames. One per line.": "ডেভপস ডাকনামের একটি তালিকা। প্রতি লাইনে একটি।", + "devops": "devops" } diff --git a/translations/ca.json b/translations/ca.json index 4026c8d68..a2a59a06e 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -590,5 +590,8 @@ "Last year": "L'any passat", "Unauthorized": "No autoritzat", "No login credentials were posted": "No s'ha publicat cap credencial d'inici de sessió", - "Credentials are too long": "Les credencials són massa llargues" + "Credentials are too long": "Les credencials són massa llargues", + "Site DevOps": "Lloc DevOps", + "A list of devops nicknames. One per line.": "Una llista de sobrenoms de devops. Un per línia.", + "devops": "devops" } diff --git a/translations/cy.json b/translations/cy.json index 5a5c76311..39e1cbf74 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -590,5 +590,8 @@ "Last year": "Blwyddyn diwethaf", "Unauthorized": "Anawdurdodedig", "No login credentials were posted": "Ni bostiwyd unrhyw fanylion mewngofnodi", - "Credentials are too long": "Mae manylion yn rhy hir" + "Credentials are too long": "Mae manylion yn rhy hir", + "Site DevOps": "Gwefan DevOps", + "A list of devops nicknames. One per line.": "Mae rhestr o devops llysenwau. Un i bob llinell.", + "devops": "devops" } diff --git a/translations/de.json b/translations/de.json index 282a36023..ed54dc3ae 100644 --- a/translations/de.json +++ b/translations/de.json @@ -590,5 +590,8 @@ "Last year": "Vergangenes Jahr", "Unauthorized": "Unbefugt", "No login credentials were posted": "Es wurden keine Zugangsdaten gepostet", - "Credentials are too long": "Anmeldeinformationen sind zu lang" + "Credentials are too long": "Anmeldeinformationen sind zu lang", + "Site DevOps": "Site-DevOps", + "A list of devops nicknames. One per line.": "Eine Liste von Entwickler-Spitznamen. Eine pro Zeile.", + "devops": "devops" } diff --git a/translations/el.json b/translations/el.json index 0778d0b58..ad9240814 100644 --- a/translations/el.json +++ b/translations/el.json @@ -590,5 +590,8 @@ "Last year": "Πέρυσι", "Unauthorized": "Ανεξουσιοδότητος", "No login credentials were posted": "Δεν δημοσιεύτηκαν διαπιστευτήρια σύνδεσης", - "Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα" + "Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα", + "Site DevOps": "DevOps ιστότοπου", + "A list of devops nicknames. One per line.": "Μια λίστα με ψευδώνυμα devops. Ένα ανά γραμμή.", + "devops": "devops" } diff --git a/translations/en.json b/translations/en.json index 7786801e4..d6967f0b6 100644 --- a/translations/en.json +++ b/translations/en.json @@ -590,5 +590,8 @@ "Last year": "Last year", "Unauthorized": "Unauthorized", "No login credentials were posted": "No login credentials were posted", - "Credentials are too long": "Credentials are too long" + "Credentials are too long": "Credentials are too long", + "Site DevOps": "Site DevOps", + "A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.", + "devops": "devops" } diff --git a/translations/es.json b/translations/es.json index ea16525b9..06df4acf8 100644 --- a/translations/es.json +++ b/translations/es.json @@ -590,5 +590,8 @@ "Last year": "El año pasado", "Unauthorized": "No autorizado", "No login credentials were posted": "No se publicaron credenciales de inicio de sesión", - "Credentials are too long": "Las credenciales son demasiado largas" + "Credentials are too long": "Las credenciales son demasiado largas", + "Site DevOps": "DevOps del sitio", + "A list of devops nicknames. One per line.": "Una lista de apodos de devops. Uno por línea.", + "devops": "devops" } diff --git a/translations/fr.json b/translations/fr.json index 6b0599a41..429424bea 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -590,5 +590,8 @@ "Last year": "L'année dernière", "Unauthorized": "Non autorisé", "No login credentials were posted": "Aucun identifiant de connexion n'a été posté", - "Credentials are too long": "Les identifiants sont trop longs" + "Credentials are too long": "Les identifiants sont trop longs", + "Site DevOps": "DevOps du site", + "A list of devops nicknames. One per line.": "Une liste de surnoms de devops. Un par ligne.", + "devops": "devops" } diff --git a/translations/ga.json b/translations/ga.json index 3d2ad5f0a..bb98400ce 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -590,5 +590,8 @@ "Last year": "Anuraidh", "Unauthorized": "Neamhúdaraithe", "No login credentials were posted": "Níor postáladh aon dintiúir logáil isteach", - "Credentials are too long": "Tá dintiúir ró-fhada" + "Credentials are too long": "Tá dintiúir ró-fhada", + "Site DevOps": "Suíomh DevOps", + "A list of devops nicknames. One per line.": "Tá liosta devops leasainmneacha. Ceann in aghaidh an líne.", + "devops": "devops" } diff --git a/translations/hi.json b/translations/hi.json index d4e2bbd42..175af9375 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -590,5 +590,8 @@ "Last year": "पिछले साल", "Unauthorized": "अनधिकृत", "No login credentials were posted": "कोई लॉगिन क्रेडेंशियल पोस्ट नहीं किया गया था", - "Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं" + "Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं", + "Site DevOps": "साइट देवऑप्स", + "A list of devops nicknames. One per line.": "देवोप्स उपनामों की एक सूची। प्रति पंक्ति एक।", + "devops": "devops" } diff --git a/translations/it.json b/translations/it.json index 122c7847a..797328064 100644 --- a/translations/it.json +++ b/translations/it.json @@ -590,5 +590,8 @@ "Last year": "L'anno scorso", "Unauthorized": "Non autorizzato", "No login credentials were posted": "Non sono state pubblicate credenziali di accesso", - "Credentials are too long": "Le credenziali sono troppo lunghe" + "Credentials are too long": "Le credenziali sono troppo lunghe", + "Site DevOps": "Sito DevOps", + "A list of devops nicknames. One per line.": "Un elenco di soprannomi devops. Uno per riga.", + "devops": "devops" } diff --git a/translations/ja.json b/translations/ja.json index ee327ae96..a54397066 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -590,5 +590,8 @@ "Last year": "去年", "Unauthorized": "無許可", "No login credentials were posted": "ログイン認証情報が投稿されていません", - "Credentials are too long": "資格情報が長すぎます" + "Credentials are too long": "資格情報が長すぎます", + "Site DevOps": "サイト DevOps", + "A list of devops nicknames. One per line.": "DevOps ニックネームのリスト。 1 行に 1 つ。", + "devops": "devops" } diff --git a/translations/ko.json b/translations/ko.json index 868b6bb4e..b6d213910 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -590,5 +590,8 @@ "Last year": "작년", "Unauthorized": "무단", "No login credentials were posted": "게시된 로그인 자격 증명이 없습니다.", - "Credentials are too long": "자격 증명이 너무 깁니다." + "Credentials are too long": "자격 증명이 너무 깁니다.", + "Site DevOps": "사이트 DevOps", + "A list of devops nicknames. One per line.": "데브옵스 닉네임 목록입니다. 한 줄에 하나씩.", + "devops": "devops" } diff --git a/translations/ku.json b/translations/ku.json index 54df7dbd3..9eb1d5a5b 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -590,5 +590,8 @@ "Last year": "Sala borî", "Unauthorized": "Bêmaf", "No login credentials were posted": "Tu pêbaweriyên têketinê nehatin şandin", - "Credentials are too long": "Bawernameyên pir dirêj in" + "Credentials are too long": "Bawernameyên pir dirêj in", + "Site DevOps": "Malpera DevOps", + "A list of devops nicknames. One per line.": "Lîsteya navên devops. Her rêzek yek.", + "devops": "devops" } diff --git a/translations/nl.json b/translations/nl.json index c454edc4d..5f3fdbf05 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -590,5 +590,8 @@ "Last year": "Afgelopen jaar", "Unauthorized": "Ongeautoriseerd", "No login credentials were posted": "Er zijn geen inloggegevens gepost", - "Credentials are too long": "Inloggegevens zijn te lang" + "Credentials are too long": "Inloggegevens zijn te lang", + "Site DevOps": "Site DevOps", + "A list of devops nicknames. One per line.": "Een lijst met devops-bijnamen. Een per regel.", + "devops": "devops" } diff --git a/translations/oc.json b/translations/oc.json index 29ec2857c..2922914c8 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -586,5 +586,8 @@ "Last year": "Last year", "Unauthorized": "Unauthorized", "No login credentials were posted": "No login credentials were posted", - "Credentials are too long": "Credentials are too long" + "Credentials are too long": "Credentials are too long", + "Site DevOps": "Site DevOps", + "A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.", + "devops": "devops" } diff --git a/translations/pl.json b/translations/pl.json index 9af7f9dcc..71449c430 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -590,5 +590,8 @@ "Last year": "Ostatni rok", "Unauthorized": "Nieautoryzowany", "No login credentials were posted": "Nie opublikowano danych logowania", - "Credentials are too long": "Poświadczenia są za długie" + "Credentials are too long": "Poświadczenia są za długie", + "Site DevOps": "Deweloperzy witryny", + "A list of devops nicknames. One per line.": "Lista pseudonimów Devopa. Jeden na linię.", + "devops": "devops" } diff --git a/translations/pt.json b/translations/pt.json index 2d7d88d55..7fecd5e19 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -590,5 +590,8 @@ "Last year": "Ano passado", "Unauthorized": "Não autorizado", "No login credentials were posted": "Nenhuma credencial de login foi postada", - "Credentials are too long": "As credenciais são muito longas" + "Credentials are too long": "As credenciais são muito longas", + "Site DevOps": "Site DevOps", + "A list of devops nicknames. One per line.": "Uma lista de apelidos de devops. Um por linha.", + "devops": "devops" } diff --git a/translations/ru.json b/translations/ru.json index 4188c23af..1b2d22ae7 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -590,5 +590,8 @@ "Last year": "Прошедший год", "Unauthorized": "Неавторизованный", "No login credentials were posted": "Учетные данные для входа не были отправлены", - "Credentials are too long": "Учетные данные слишком длинные" + "Credentials are too long": "Учетные данные слишком длинные", + "Site DevOps": "DevOps сайта", + "A list of devops nicknames. One per line.": "Список псевдонимов devops. По одному на строку.", + "devops": "devops" } diff --git a/translations/sw.json b/translations/sw.json index 30dc696ac..caedc04fa 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -590,5 +590,8 @@ "Last year": "Mwaka jana", "Unauthorized": "Haijaidhinishwa", "No login credentials were posted": "Hakuna kitambulisho cha kuingia kilichochapishwa", - "Credentials are too long": "Kitambulisho ni kirefu sana" + "Credentials are too long": "Kitambulisho ni kirefu sana", + "Site DevOps": "Tovuti ya DevOps", + "A list of devops nicknames. One per line.": "Orodha ya majina ya utani ya devops. Moja kwa kila mstari.", + "devops": "devops" } diff --git a/translations/tr.json b/translations/tr.json index efcc36f80..e8ab86a9b 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -590,5 +590,8 @@ "Last year": "Geçen yıl", "Unauthorized": "Yetkisiz", "No login credentials were posted": "Giriş bilgileri gönderilmedi", - "Credentials are too long": "Kimlik bilgileri çok uzun" + "Credentials are too long": "Kimlik bilgileri çok uzun", + "Site DevOps": "Site DevOps", + "A list of devops nicknames. One per line.": "Devops takma adlarının listesi. Her satıra bir tane.", + "devops": "devops" } diff --git a/translations/uk.json b/translations/uk.json index 923d202d4..9bfaeb396 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -590,5 +590,8 @@ "Last year": "Минулого року", "Unauthorized": "Несанкціонований", "No login credentials were posted": "Облікові дані для входу не опубліковано", - "Credentials are too long": "Облікові дані задовгі" + "Credentials are too long": "Облікові дані задовгі", + "Site DevOps": "Сайт DevOps", + "A list of devops nicknames. One per line.": "Список ніків devops. По одному на рядок.", + "devops": "devops" } diff --git a/translations/yi.json b/translations/yi.json index a52868036..43588504b 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -590,5 +590,8 @@ "Last year": "לעצטע יאר", "Unauthorized": "אַנאָטערייזד", "No login credentials were posted": "קיין לאָגין קראַדענטשאַלז זענען אַרייַנגעשיקט", - "Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג" + "Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג", + "Site DevOps": "וועבזייטל DevOps", + "A list of devops nicknames. One per line.": "א רשימה פון דיוואָפּס ניקניימז. איינער פּער שורה.", + "devops": "devops" } diff --git a/translations/zh.json b/translations/zh.json index 546709ed7..cd19651a4 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -590,5 +590,8 @@ "Last year": "去年", "Unauthorized": "未经授权", "No login credentials were posted": "未发布登录凭据", - "Credentials are too long": "凭据太长" + "Credentials are too long": "凭据太长", + "Site DevOps": "站点 DevOps", + "A list of devops nicknames. One per line.": "devops 昵称列表。 每行一个。", + "devops": "devops" } diff --git a/webapp_profile.py b/webapp_profile.py index b7129b0f6..4115a148c 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -82,6 +82,7 @@ from webapp_timeline import page_number_buttons from blocking import get_cw_list_variable from blocking import is_blocked from content import bold_reading_string +from roles import is_devops THEME_FORMATS = '.zip, .gz' @@ -1543,6 +1544,22 @@ def _html_edit_profile_instance(base_dir: str, translate: {}, role_assign_str += \ edit_text_area(translate['Artists'], 'artists', artists, 200, '', False) + + # site devops + devops = '' + devops_file = base_dir + '/accounts/devops.txt' + if os.path.isfile(devops_file): + with open(devops_file, 'r', encoding='utf-8') as edit_file: + devops = edit_file.read() + role_assign_str += \ + '
\n' + \ + ' ' + \ + translate['A list of devops nicknames. One per line.'] + \ + ' ' + role_assign_str += end_edit_section() # Video section @@ -2420,7 +2437,8 @@ def html_edit_profile(server, translate: {}, media_instance_str, blogs_instance_str, news_instance_str) - system_monitor_str = _html_system_monitor(nickname, translate) + if is_devops(base_dir, nickname): + system_monitor_str = _html_system_monitor(nickname, translate) instance_title = get_config_param(base_dir, 'instanceTitle') edit_profile_form = \