From da07855e973e86c8bc1f4a223fc431dac471cf81 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 17 May 2021 17:13:56 +0100 Subject: [PATCH 1/5] Artist role --- daemon.py | 57 ++++++++++++++++++++++++++++++++++++++++++++ roles.py | 13 +++++++++- tests.py | 1 + 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/ku.json | 3 ++- translations/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/zh.json | 3 ++- webapp_profile.py | 15 ++++++++++++ 20 files changed, 117 insertions(+), 17 deletions(-) diff --git a/daemon.py b/daemon.py index 491eeb781..a75dca7cf 100644 --- a/daemon.py +++ b/daemon.py @@ -128,6 +128,7 @@ from roles import setRole from roles import clearModeratorStatus from roles import clearEditorStatus from roles import clearCounselorStatus +from roles import clearArtistStatus from blog import htmlBlogPageRSS2 from blog import htmlBlogPageRSS3 from blog import htmlBlogView @@ -4872,6 +4873,62 @@ class PubServer(BaseHTTPRequestHandler): edNick, domain, 'counselor') + # change site artists list + if fields.get('artists'): + if path.startswith('/users/' + + adminNickname + '/'): + artistsFile = \ + baseDir + \ + '/accounts/artists.txt' + clearArtistStatus(baseDir) + if ',' in fields['artists']: + # if the list was given as comma separated + edFile = open(artistsFile, "w+") + eds = fields['artists'].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['artists'].split(',') + for edNick in eds: + edNick = edNick.strip() + edDir = baseDir + \ + '/accounts/' + edNick + \ + '@' + domain + if os.path.isdir(edDir): + setRole(baseDir, + edNick, domain, + 'artist') + else: + # nicknames on separate lines + edFile = open(artistsFile, "w+") + eds = fields['artists'].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['artists'].split('\n') + for edNick in eds: + edNick = edNick.strip() + edDir = \ + baseDir + \ + '/accounts/' + \ + edNick + '@' + \ + domain + if os.path.isdir(edDir): + setRole(baseDir, + edNick, domain, + 'artist') + # remove scheduled posts if fields.get('removeScheduledPosts'): if fields['removeScheduledPosts'] == 'on': diff --git a/roles.py b/roles.py index 9e2672af2..a3d139971 100644 --- a/roles.py +++ b/roles.py @@ -54,6 +54,14 @@ def clearCounselorStatus(baseDir: str) -> None: _clearRoleStatus(baseDir, 'editor') +def clearArtistStatus(baseDir: str) -> None: + """Removes artist status from all accounts + This could be slow if there are many users, but only happens + rarely when artists are appointed or removed + """ + _clearRoleStatus(baseDir, 'artist') + + def clearModeratorStatus(baseDir: str) -> None: """Removes moderator status from all accounts This could be slow if there are many users, but only happens @@ -126,6 +134,8 @@ def _setActorRole(actorJson: {}, roleName: str) -> bool: category = '27-3041.00' elif 'counselor' in roleName: category = '23-1022.00' + elif 'artist' in roleName: + category = '27-1024.00' if not category: return False @@ -225,7 +235,8 @@ def setRole(baseDir: str, nickname: str, domain: str, roleFiles = { "moderator": "moderators.txt", "editor": "editors.txt", - "counselor": "counselors.txt" + "counselor": "counselors.txt", + "artist": "artists.txt" } actorJson = loadJson(actorFilename) diff --git a/tests.py b/tests.py index 6155b42eb..fc4ae487f 100644 --- a/tests.py +++ b/tests.py @@ -3706,6 +3706,7 @@ def testRoles() -> None: assert actorHasRole(actorJson, "moderator") assert not actorHasRole(actorJson, "editor") assert not actorHasRole(actorJson, "counselor") + assert not actorHasRole(actorJson, "artist") def runAllTests(): diff --git a/translations/ar.json b/translations/ar.json index e06f1bf25..840867db3 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "إظهار رقم الإصدار داخل البيانات الوصفية للمثيل", "Joined": "تاريخ الانضمام", "City for spoofed GPS image metadata": "مدينة للبيانات الوصفية لصور GPS المخادعة", - "Occupation": "الاحتلال" + "Occupation": "الاحتلال", + "Artists": "الفنانين" } diff --git a/translations/ca.json b/translations/ca.json index b7fbfdc6a..f1c1fca10 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Mostra el número de versió a les metadades de la instància", "Joined": "Data d'unió", "City for spoofed GPS image metadata": "Ciutat per a metadades d'imatges GPS falsificades", - "Occupation": "Ocupació" + "Occupation": "Ocupació", + "Artists": "Artistes" } diff --git a/translations/cy.json b/translations/cy.json index 03a6dc09d..40b5fe58b 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Dangos rhif y fersiwn o fewn metadata", "Joined": "Dyddiad ymuno", "City for spoofed GPS image metadata": "Dinas ar gyfer metadata delwedd GPS spoofed", - "Occupation": "Ngalwedigaeth" + "Occupation": "Ngalwedigaeth", + "Artists": "Artistiaid" } diff --git a/translations/de.json b/translations/de.json index f193a603e..e41a714ad 100644 --- a/translations/de.json +++ b/translations/de.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Versionsnummer in Instanzmetadaten anzeigen", "Joined": "Verbundenes Datum", "City for spoofed GPS image metadata": "Stadt für gefälschte GPS-Bildmetadaten", - "Occupation": "Besetzung" + "Occupation": "Besetzung", + "Artists": "Künstler" } diff --git a/translations/en.json b/translations/en.json index 3216f1d53..59d1dbe25 100644 --- a/translations/en.json +++ b/translations/en.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Show version number within instance metadata", "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", - "Occupation": "Occupation" + "Occupation": "Occupation", + "Artists": "Artists" } diff --git a/translations/es.json b/translations/es.json index b966a4777..9c0a37375 100644 --- a/translations/es.json +++ b/translations/es.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Mostrar el número de versión dentro de los metadatos de la instancia", "Joined": "Fecha unida", "City for spoofed GPS image metadata": "Ciudad para metadatos de imagen GPS falsificados", - "Occupation": "Ocupación" + "Occupation": "Ocupación", + "Artists": "Artistas" } diff --git a/translations/fr.json b/translations/fr.json index 197c319fa..da8960e5f 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Afficher le numéro de version dans les métadonnées de l'instance", "Joined": "Joint", "City for spoofed GPS image metadata": "Ville pour les métadonnées d'image GPS falsifiées", - "Occupation": "Occupation" + "Occupation": "Occupation", + "Artists": "Artistes" } diff --git a/translations/ga.json b/translations/ga.json index 549abadce..eb408a367 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Taispeáin uimhir an leagain laistigh de mheiteashonraí", "Joined": "Dáta comhcheangailte", "City for spoofed GPS image metadata": "Cathair le haghaidh meiteashonraí íomhá GPS spoofed", - "Occupation": "Slí bheatha" + "Occupation": "Slí bheatha", + "Artists": "Ealaíontóirí" } diff --git a/translations/hi.json b/translations/hi.json index 8d42d418c..50d671084 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "उदाहरण मेटाडेटा के भीतर संस्करण संख्या दिखाएं", "Joined": "दिनांक", "City for spoofed GPS image metadata": "स्पूफ जीपीएस जीपीएस मेटाडेटा के लिए शहर", - "Occupation": "व्यवसाय" + "Occupation": "व्यवसाय", + "Artists": "कलाकार की" } diff --git a/translations/it.json b/translations/it.json index 3557bbd26..a3c118e9a 100644 --- a/translations/it.json +++ b/translations/it.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Mostra il numero di versione nei metadati dell'istanza", "Joined": "Unito", "City for spoofed GPS image metadata": "Città per metadati di immagini GPS falsificate", - "Occupation": "Occupazione" + "Occupation": "Occupazione", + "Artists": "Artiste" } diff --git a/translations/ja.json b/translations/ja.json index 04de4d1fd..efa074b6c 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "インスタンスメタデータ内にバージョン番号を表示する", "Joined": "参加日", "City for spoofed GPS image metadata": "なりすましGPS画像メタデータの都市", - "Occupation": "職業" + "Occupation": "職業", + "Artists": "アーティスト" } diff --git a/translations/ku.json b/translations/ku.json index bb69bf5e2..02c086a7a 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Di nav metadata mînakê de nimreya guhertoyê nîşan bide", "Joined": "Beşdarbûna Dîrokê", "City for spoofed GPS image metadata": "Bajar ji bo metadata wêneya GPS ya xapînok", - "Occupation": "Sinet" + "Occupation": "Sinet", + "Artists": "Hunermend" } diff --git a/translations/oc.json b/translations/oc.json index f9d2fe53b..518eae8fb 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -438,5 +438,6 @@ "Show version number within instance metadata": "Show version number within instance metadata", "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", - "Occupation": "Occupation" + "Occupation": "Occupation", + "Artists": "Artists" } diff --git a/translations/pt.json b/translations/pt.json index 956805c99..b879a81e4 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Mostrar o número da versão nos metadados da instância", "Joined": "Data juntada", "City for spoofed GPS image metadata": "Cidade para metadados de imagem GPS falsificados", - "Occupation": "Ocupação" + "Occupation": "Ocupação", + "Artists": "Artistas" } diff --git a/translations/ru.json b/translations/ru.json index 6a29ea88b..2c69993fe 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "Показать номер версии в метаданных экземпляра", "Joined": "Присоединенная дата", "City for spoofed GPS image metadata": "Город для поддельных метаданных изображения GPS", - "Occupation": "Занятие" + "Occupation": "Занятие", + "Artists": "Художники" } diff --git a/translations/zh.json b/translations/zh.json index 80222724e..04d1893dc 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -442,5 +442,6 @@ "Show version number within instance metadata": "在实例元数据中显示版本号", "Joined": "加入日期", "City for spoofed GPS image metadata": "欺骗性GPS影像元数据的城市", - "Occupation": "职业" + "Occupation": "职业", + "Artists": "艺人" } diff --git a/webapp_profile.py b/webapp_profile.py index 5ec33c1c9..33e9cbf01 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1500,6 +1500,21 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, counselors + '' roleAssignStr += ' \n' + # artists + artists = '' + artistsFile = baseDir + '/accounts/artists.txt' + if os.path.isfile(artistsFile): + with open(artistsFile, "r") as f: + artists = f.read() + roleAssignStr += '
\n' + roleAssignStr += \ + ' ' + roleAssignStr += ' \n' + # Video section peertubeStr = '
' + \ translate['Video Settings'] + '\n' From 46687f8b6d45a476da39cee8695462e625d50590 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 17 May 2021 17:16:15 +0100 Subject: [PATCH 2/5] Roles section in profile --- webapp_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp_profile.py b/webapp_profile.py index 33e9cbf01..5abbea6af 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1498,7 +1498,6 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, 'placeholder="" ' + \ 'style="height:200px" spellcheck="false">' + \ counselors + '' - roleAssignStr += '
\n' # artists artists = '' From 7a78f8e7d869fdb7ab8c8cce52e1dac76dadc6ed Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 17 May 2021 18:52:33 +0100 Subject: [PATCH 3/5] Graphic design section on edit profile screen --- daemon.py | 103 ++++++++++++++++++++++++------------------- 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/ku.json | 3 +- translations/oc.json | 3 +- translations/pt.json | 3 +- translations/ru.json | 3 +- translations/zh.json | 3 +- utils.py | 28 ++++++++++++ webapp_profile.py | 80 ++++++++++++++++++--------------- 19 files changed, 162 insertions(+), 97 deletions(-) diff --git a/daemon.py b/daemon.py index a75dca7cf..b3c939fcc 100644 --- a/daemon.py +++ b/daemon.py @@ -214,6 +214,7 @@ from utils import hasUsersPath from utils import getFullDomain from utils import removeHtml from utils import isEditor +from utils import isArtist from utils import getImageExtensions from utils import mediaFileMimeType from utils import getCSS @@ -4269,6 +4270,38 @@ class PubServer(BaseHTTPRequestHandler): if checkNameAndBio: redirectPath = 'previewAvatar' + if nickname == adminNickname or \ + isArtist(baseDir, nickname): + # change theme + if fields.get('themeDropdown'): + self.server.themeName = fields['themeDropdown'] + setTheme(baseDir, self.server.themeName, domain, + allowLocalNetworkAccess, systemLanguage) + self.server.textModeBanner = \ + getTextModeBanner(self.server.baseDir) + self.server.iconsCache = {} + self.server.fontsCache = {} + self.server.showPublishAsIcon = \ + getConfigParam(self.server.baseDir, + 'showPublishAsIcon') + self.server.fullWidthTimelineButtonHeader = \ + getConfigParam(self.server.baseDir, + 'fullWidthTimelineButtonHeader') + self.server.iconsAsButtons = \ + getConfigParam(self.server.baseDir, + 'iconsAsButtons') + self.server.rssIconAtTop = \ + getConfigParam(self.server.baseDir, + 'rssIconAtTop') + self.server.publishButtonAtTop = \ + getConfigParam(self.server.baseDir, + 'publishButtonAtTop') + setNewsAvatar(baseDir, + fields['themeDropdown'], + httpPrefix, + domain, + domainFull) + if nickname == adminNickname: # change media instance status if fields.get('mediaInstance'): @@ -4353,36 +4386,6 @@ class PubServer(BaseHTTPRequestHandler): "blogsInstance", self.server.blogsInstance) - # change theme - if fields.get('themeDropdown'): - self.server.themeName = fields['themeDropdown'] - setTheme(baseDir, self.server.themeName, domain, - allowLocalNetworkAccess, systemLanguage) - self.server.textModeBanner = \ - getTextModeBanner(self.server.baseDir) - self.server.iconsCache = {} - self.server.fontsCache = {} - self.server.showPublishAsIcon = \ - getConfigParam(self.server.baseDir, - 'showPublishAsIcon') - self.server.fullWidthTimelineButtonHeader = \ - getConfigParam(self.server.baseDir, - 'fullWidthTimelineButtonHeader') - self.server.iconsAsButtons = \ - getConfigParam(self.server.baseDir, - 'iconsAsButtons') - self.server.rssIconAtTop = \ - getConfigParam(self.server.baseDir, - 'rssIconAtTop') - self.server.publishButtonAtTop = \ - getConfigParam(self.server.baseDir, - 'publishButtonAtTop') - setNewsAvatar(baseDir, - fields['themeDropdown'], - httpPrefix, - domain, - domainFull) - # change instance title if fields.get('instanceTitle'): currInstanceTitle = \ @@ -4953,7 +4956,10 @@ class PubServer(BaseHTTPRequestHandler): # remove a custom font if fields.get('removeCustomFont'): - if fields['removeCustomFont'] == 'on': + if (fields['removeCustomFont'] == 'on' and + (isArtist(baseDir, nickname) or + path.startswith('/users/' + + adminNickname + '/'))): fontExt = ('woff', 'woff2', 'otf', 'ttf') for ext in fontExt: if os.path.isfile(baseDir + @@ -4969,28 +4975,30 @@ class PubServer(BaseHTTPRequestHandler): currTheme = getTheme(baseDir) if currTheme: self.server.themeName = currTheme + allowLocalNetworkAccess = \ + self.server.allowLocalNetworkAccess setTheme(baseDir, currTheme, domain, - self.server.allowLocalNetworkAccess, + allowLocalNetworkAccess, systemLanguage) self.server.textModeBanner = \ - getTextModeBanner(self.server.baseDir) + getTextModeBanner(baseDir) self.server.iconsCache = {} self.server.fontsCache = {} self.server.showPublishAsIcon = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'showPublishAsIcon') self.server.fullWidthTimelineButtonHeader = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'fullWidthTimeline' + 'ButtonHeader') self.server.iconsAsButtons = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'iconsAsButtons') self.server.rssIconAtTop = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'rssIconAtTop') self.server.publishButtonAtTop = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'publishButtonAtTop') # only receive DMs from accounts you follow @@ -5090,14 +5098,17 @@ class PubServer(BaseHTTPRequestHandler): actorChanged = True # grayscale theme - grayscale = False - if fields.get('grayscale'): - if fields['grayscale'] == 'on': - grayscale = True - if grayscale: - enableGrayscale(baseDir) - else: - disableGrayscale(baseDir) + if path.startswith('/users/' + + adminNickname + '/') or \ + isArtist(baseDir, nickname): + grayscale = False + if fields.get('grayscale'): + if fields['grayscale'] == 'on': + grayscale = True + if grayscale: + enableGrayscale(baseDir) + else: + disableGrayscale(baseDir) # save filtered words list filterFilename = \ diff --git a/translations/ar.json b/translations/ar.json index 840867db3..3c148225a 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -443,5 +443,6 @@ "Joined": "تاريخ الانضمام", "City for spoofed GPS image metadata": "مدينة للبيانات الوصفية لصور GPS المخادعة", "Occupation": "الاحتلال", - "Artists": "الفنانين" + "Artists": "الفنانين", + "Graphic Design": "التصميم الجرافيكي" } diff --git a/translations/ca.json b/translations/ca.json index f1c1fca10..ac083d8b0 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -443,5 +443,6 @@ "Joined": "Data d'unió", "City for spoofed GPS image metadata": "Ciutat per a metadades d'imatges GPS falsificades", "Occupation": "Ocupació", - "Artists": "Artistes" + "Artists": "Artistes", + "Graphic Design": "Disseny gràfic" } diff --git a/translations/cy.json b/translations/cy.json index 40b5fe58b..92be8ccfc 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -443,5 +443,6 @@ "Joined": "Dyddiad ymuno", "City for spoofed GPS image metadata": "Dinas ar gyfer metadata delwedd GPS spoofed", "Occupation": "Ngalwedigaeth", - "Artists": "Artistiaid" + "Artists": "Artistiaid", + "Graphic Design": "Dylunio Graffig" } diff --git a/translations/de.json b/translations/de.json index e41a714ad..9d21db01f 100644 --- a/translations/de.json +++ b/translations/de.json @@ -443,5 +443,6 @@ "Joined": "Verbundenes Datum", "City for spoofed GPS image metadata": "Stadt für gefälschte GPS-Bildmetadaten", "Occupation": "Besetzung", - "Artists": "Künstler" + "Artists": "Künstler", + "Graphic Design": "Grafikdesign" } diff --git a/translations/en.json b/translations/en.json index 59d1dbe25..f7b950842 100644 --- a/translations/en.json +++ b/translations/en.json @@ -443,5 +443,6 @@ "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", "Occupation": "Occupation", - "Artists": "Artists" + "Artists": "Artists", + "Graphic Design": "Graphic Design" } diff --git a/translations/es.json b/translations/es.json index 9c0a37375..9f79db640 100644 --- a/translations/es.json +++ b/translations/es.json @@ -443,5 +443,6 @@ "Joined": "Fecha unida", "City for spoofed GPS image metadata": "Ciudad para metadatos de imagen GPS falsificados", "Occupation": "Ocupación", - "Artists": "Artistas" + "Artists": "Artistas", + "Graphic Design": "Diseño gráfico" } diff --git a/translations/fr.json b/translations/fr.json index da8960e5f..bdc6e3280 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -443,5 +443,6 @@ "Joined": "Joint", "City for spoofed GPS image metadata": "Ville pour les métadonnées d'image GPS falsifiées", "Occupation": "Occupation", - "Artists": "Artistes" + "Artists": "Artistes", + "Graphic Design": "Conception graphique" } diff --git a/translations/ga.json b/translations/ga.json index eb408a367..2755d94a0 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -443,5 +443,6 @@ "Joined": "Dáta comhcheangailte", "City for spoofed GPS image metadata": "Cathair le haghaidh meiteashonraí íomhá GPS spoofed", "Occupation": "Slí bheatha", - "Artists": "Ealaíontóirí" + "Artists": "Ealaíontóirí", + "Graphic Design": "Dearadh grafach" } diff --git a/translations/hi.json b/translations/hi.json index 50d671084..77cd7bb76 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -443,5 +443,6 @@ "Joined": "दिनांक", "City for spoofed GPS image metadata": "स्पूफ जीपीएस जीपीएस मेटाडेटा के लिए शहर", "Occupation": "व्यवसाय", - "Artists": "कलाकार की" + "Artists": "कलाकार की", + "Graphic Design": "ग्राफ़िक डिज़ाइन" } diff --git a/translations/it.json b/translations/it.json index a3c118e9a..cd8b2cd25 100644 --- a/translations/it.json +++ b/translations/it.json @@ -443,5 +443,6 @@ "Joined": "Unito", "City for spoofed GPS image metadata": "Città per metadati di immagini GPS falsificate", "Occupation": "Occupazione", - "Artists": "Artiste" + "Artists": "Artiste", + "Graphic Design": "Graphic design" } diff --git a/translations/ja.json b/translations/ja.json index efa074b6c..25935464c 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -443,5 +443,6 @@ "Joined": "参加日", "City for spoofed GPS image metadata": "なりすましGPS画像メタデータの都市", "Occupation": "職業", - "Artists": "アーティスト" + "Artists": "アーティスト", + "Graphic Design": "グラフィックデザイン" } diff --git a/translations/ku.json b/translations/ku.json index 02c086a7a..b4dd76fc2 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -443,5 +443,6 @@ "Joined": "Beşdarbûna Dîrokê", "City for spoofed GPS image metadata": "Bajar ji bo metadata wêneya GPS ya xapînok", "Occupation": "Sinet", - "Artists": "Hunermend" + "Artists": "Hunermend", + "Graphic Design": "Sêwirana grafîkî" } diff --git a/translations/oc.json b/translations/oc.json index 518eae8fb..b57a869f4 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -439,5 +439,6 @@ "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", "Occupation": "Occupation", - "Artists": "Artists" + "Artists": "Artists", + "Graphic Design": "Graphic Design" } diff --git a/translations/pt.json b/translations/pt.json index b879a81e4..aa3508853 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -443,5 +443,6 @@ "Joined": "Data juntada", "City for spoofed GPS image metadata": "Cidade para metadados de imagem GPS falsificados", "Occupation": "Ocupação", - "Artists": "Artistas" + "Artists": "Artistas", + "Graphic Design": "Design gráfico" } diff --git a/translations/ru.json b/translations/ru.json index 2c69993fe..6aad20e8f 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -443,5 +443,6 @@ "Joined": "Присоединенная дата", "City for spoofed GPS image metadata": "Город для поддельных метаданных изображения GPS", "Occupation": "Занятие", - "Artists": "Художники" + "Artists": "Художники", + "Graphic Design": "Графический дизайн" } diff --git a/translations/zh.json b/translations/zh.json index 04d1893dc..81287ecc1 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -443,5 +443,6 @@ "Joined": "加入日期", "City for spoofed GPS image metadata": "欺骗性GPS影像元数据的城市", "Occupation": "职业", - "Artists": "艺人" + "Artists": "艺人", + "Graphic Design": "平面设计" } diff --git a/utils.py b/utils.py index c478158d7..0a54a3148 100644 --- a/utils.py +++ b/utils.py @@ -194,6 +194,34 @@ def isEditor(baseDir: str, nickname: str) -> bool: return False +def isArtist(baseDir: str, nickname: str) -> bool: + """Returns true if the given nickname is an artist + """ + artistsFile = baseDir + '/accounts/artists.txt' + + if not os.path.isfile(artistsFile): + adminName = getConfigParam(baseDir, 'admin') + if not adminName: + return False + if adminName == nickname: + return True + return False + + with open(artistsFile, "r") as f: + lines = f.readlines() + if len(lines) == 0: + adminName = getConfigParam(baseDir, 'admin') + if not adminName: + return False + if adminName == nickname: + return True + for artist in lines: + artist = artist.strip('\n').strip('\r') + if artist == nickname: + return True + return False + + def getImageExtensions() -> []: """Returns a list of the possible image file extensions """ diff --git a/webapp_profile.py b/webapp_profile.py index 5abbea6af..71a4e32df 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -12,6 +12,7 @@ from utils import getOccupationName from utils import getLockedAccount from utils import hasUsersPath from utils import getFullDomain +from utils import isArtist from utils import isDormant from utils import getNicknameFromActor from utils import getDomainFromActor @@ -1292,6 +1293,49 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, peertubeStr = '' adminNickname = getConfigParam(baseDir, 'admin') + + if isArtist(baseDir, nickname) or \ + path.startswith('/users/' + str(adminNickname) + '/'): + graphicsStr = '
' + \ + translate['Graphic Design'] + '\n' + graphicsStr += '
' + + # Themes section + themes = getThemesList(baseDir) + themesDropdown += '

\n' + grayscaleFilename = \ + baseDir + '/accounts/.grayscale' + grayscale = '' + if os.path.isfile(grayscaleFilename): + grayscale = 'checked' + themesDropdown += \ + ' ' + translate['Grayscale'] + '
' + themesDropdown += '
' + if os.path.isfile(baseDir + '/fonts/custom.woff') or \ + os.path.isfile(baseDir + '/fonts/custom.woff2') or \ + os.path.isfile(baseDir + '/fonts/custom.otf') or \ + os.path.isfile(baseDir + '/fonts/custom.ttf'): + themesDropdown += \ + ' ' + \ + translate['Remove the custom font'] + '
' + themeName = getConfigParam(baseDir, 'theme') + themesDropdown = \ + themesDropdown.replace('
\n' + if adminNickname: if path.startswith('/users/' + adminNickname + '/'): # Instance details section @@ -1346,40 +1390,6 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, '
\n' - # Themes section - themes = getThemesList(baseDir) - themesDropdown += '

\n' - grayscaleFilename = \ - baseDir + '/accounts/.grayscale' - grayscale = '' - if os.path.isfile(grayscaleFilename): - grayscale = 'checked' - themesDropdown += \ - ' ' + translate['Grayscale'] + '
' - themesDropdown += '
' - if os.path.isfile(baseDir + '/fonts/custom.woff') or \ - os.path.isfile(baseDir + '/fonts/custom.woff2') or \ - os.path.isfile(baseDir + '/fonts/custom.otf') or \ - os.path.isfile(baseDir + '/fonts/custom.ttf'): - themesDropdown += \ - ' ' + \ - translate['Remove the custom font'] + '
' - themeName = getConfigParam(baseDir, 'theme') - themesDropdown = \ - themesDropdown.replace('