From b88e13055a7a340abd97992bb5816e184cda0095 Mon Sep 17 00:00:00 2001 From: Avris Date: Thu, 26 Aug 2021 14:25:59 +0200 Subject: [PATCH] #256 credentials --- locale/pl/translations.suml | 12 +++++++++ migrations/035-credentials.sql | 40 +++++++++++++++++++++++++++++ plugins/link.js | 4 +++ routes/profileEditor.vue | 46 ++++++++++++++++++++++++++++++++++ routes/team.vue | 44 ++++++++++++++++++++++++++++++++ server/routes/admin.js | 5 +++- server/routes/profile.js | 6 +++++ 7 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 migrations/035-credentials.sql diff --git a/locale/pl/translations.suml b/locale/pl/translations.suml index 24f39f44..978bb3c0 100644 --- a/locale/pl/translations.suml +++ b/locale/pl/translations.suml @@ -930,6 +930,18 @@ contact: members: 'Obecny skład' member: 'Osoba członkowska kolektywu' upcoming: 'Nadchodzące wersje językowe' + credentials: + header: 'Kwalifikacje' + description: + - > + Promujemy postrzeganie kształtowania języka jako procesu oddolnego, + w którym uczestniczy każda używająca go osoba, dlatego „legitymizując” naszą działalność + wolimy skupiać się raczej na fakcie bycia po prostu + 1) osobami używającymi języka polskiego, 2) osobami niebinarnymi i sojuszniczymi. + Wszystkie mamy prawo kształtować nasz język! + - > + Rozumiemy też jednak, że aby niektóre osoby brały nas na poważnie, + musimy podzielić się naszym formalnym wykształceniem. Oto zatem (niepełna) lista: support: header: 'Wsparcie' diff --git a/migrations/035-credentials.sql b/migrations/035-credentials.sql new file mode 100644 index 00000000..881e037b --- /dev/null +++ b/migrations/035-credentials.sql @@ -0,0 +1,40 @@ +-- Up + +ALTER TABLE profiles ADD COLUMN credentials TEXT NULL DEFAULT NULL; +ALTER TABLE profiles ADD COLUMN credentialsLevel INTEGER NULL DEFAULT NULL; +ALTER TABLE profiles ADD COLUMN credentialsName INTEGER NULL DEFAULT NULL; + +UPDATE profiles +SET credentials = 'magistra filologii angielskiej', + credentialsLevel = 5, + credentialsName = 'Karolina Grenda' +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'kafka'); + +UPDATE profiles +SET credentials = 'magister filologii angielskiej|student filologii hiszpańskiej', + credentialsLevel = 5 +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'ausir'); + +UPDATE profiles +SET credentials = 'magistra filologii słowiańskiej (z językiem czeskim) i filologii polskiej na UAM|{http://gazetylokalne.pl/sgl-local-press-2018-nominacje/=dziennikarka nominowana do SGL Local Press 2018 za reportaż „Film »Kler« i kler wrzesiński”}', + credentialsLevel = 5, + credentialsName = 'Anna Tess Gołębiowska' +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'tess'); + +UPDATE profiles +SET credentials = 'magistru językoznawstwa', + credentialsLevel = 5 +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'cake'); + +UPDATE profiles +SET credentials = 'magister językoznawstwa|absolwent Gender Studies w PAN|doktorant w Instytucie Anglistyki UW|https://orcid.org/0000-0002-0214-0387', + credentialsLevel = 6 +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'szymon'); + +UPDATE profiles +SET credentials = 'inżynierze Informatyki|finaliszcze Olimpiady Literatury i Języka Polskiego', + credentialsLevel = 1 +WHERE locale = 'pl' AND userId = (SELECT id FROM users WHERE usernameNorm = 'andrea'); + +-- Down + diff --git a/plugins/link.js b/plugins/link.js index 1e1d2808..91fe5c7b 100644 --- a/plugins/link.js +++ b/plugins/link.js @@ -46,6 +46,10 @@ const LINK_PROVIDERS = { homepage: 'https://cake.avris.it', name: 'Attraction Layer Cake', }, + orcid: { + regex: '^https?://(?:www.)?orcid.org/([^/]+)', + icon: 'https://orcid.org/assets/icons/favicon.ico', + }, }; export default { diff --git a/routes/profileEditor.vue b/routes/profileEditor.vue index 448cc93b..a6535882 100644 --- a/routes/profileEditor.vue +++ b/routes/profileEditor.vue @@ -50,6 +50,40 @@ + +
@@ -211,6 +245,9 @@ teamName: profile.teamName, footerName: profile.footerName, footerAreas: profile.footerAreas, + credentials: profile.credentials, + credentialsLevel: profile.credentialsLevel, + credentialsName: profile.credentialsName, }; } } @@ -232,6 +269,9 @@ teamName: profile.teamName, footerName: profile.footerName, footerAreas: [], + credentials: [], + credentialsLevel: null, + credentialsName: null, }; } @@ -247,6 +287,9 @@ teamName: '', footerName: '', footerAreas: [], + credentials: [], + credentialsLevel: null, + credentialsName: null, }; }, mounted() { @@ -271,6 +314,9 @@ teamName: this.teamName, footerName: this.footerName, footerAreas: this.footerAreas, + credentials: this.credentials, + credentialsLevel: this.credentialsLevel, + credentialsName: this.credentialsName, }); this.$router.push(`/@${this.$user().username}`); } finally { diff --git a/routes/team.vue b/routes/team.vue index 81ed204d..11558044 100644 --- a/routes/team.vue +++ b/routes/team.vue @@ -25,6 +25,30 @@ +
+

+ + contact.team.credentials.header +

+ + contact.team.credentials.description + + +
+

@@ -76,6 +100,26 @@ membersByLocale: await app.$axios.$get(`/admin/list`), } }, + computed: { + credentials() { + const r = []; + for (let locale in this.membersByLocale) { + if (!this.membersByLocale.hasOwnProperty(locale)) { continue; } + for (let member of this.membersByLocale[locale]) { + if (member.locale === this.config.locale && member.credentials !== null) { + r.push(member); + } + } + } + + return r.sort((a, b) => { + if (a.credentialsLevel > b.credentialsLevel) { return -1; } + if (a.credentialsLevel < b.credentialsLevel) { return 1; } + + return Math.random() > 0.5 ? 1 : -1; + }); + }, + }, } diff --git a/server/routes/admin.js b/server/routes/admin.js index 9b208963..5d1c0f1a 100644 --- a/server/routes/admin.js +++ b/server/routes/admin.js @@ -13,7 +13,7 @@ const router = Router(); router.get('/admin/list', handleErrorAsync(async (req, res) => { return res.json(await caches.admins.fetch(async () => { const admins = await req.db.all(SQL` - SELECT u.username, p.teamName, p.locale, u.id, u.email, u.avatarSource + SELECT u.username, p.teamName, p.locale, u.id, u.email, u.avatarSource, p.credentials, p.credentialsLevel, p.credentialsName FROM users u LEFT JOIN profiles p ON p.userId = u.id WHERE p.teamName IS NOT NULL @@ -34,6 +34,9 @@ router.get('/admin/list', handleErrorAsync(async (req, res) => { admin.avatar = await avatar(req.db, admin); delete admin.id; delete admin.email; + if (admin.credentials) { + admin.credentials = admin.credentials.split('|'); + } if (adminsGroupped[admin.locale] !== undefined) { adminsGroupped[admin.locale].push(admin); diff --git a/server/routes/profile.js b/server/routes/profile.js index 24e14475..d6ca9cca 100644 --- a/server/routes/profile.js +++ b/server/routes/profile.js @@ -47,6 +47,9 @@ const fetchProfiles = async (db, username, self, isAdmin) => { teamName: profile.teamName, footerName: profile.footerName, footerAreas: profile.footerAreas ? profile.footerAreas.split(',') : [], + credentials: profile.credentials ? profile.credentials.split('|') : [], + credentialsLevel: profile.credentialsLevel, + credentialsName: profile.credentialsName, card: profile.card, }; } @@ -160,6 +163,9 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => { teamName = ${req.isGranted() ? req.body.teamName || null : ''}, footerName = ${req.isGranted() ? req.body.footerName || null : ''}, footerAreas = ${req.isGranted() ? req.body.footerAreas.join(',') || null : ''}, + credentials = ${req.isGranted() ? req.body.credentials.join('|') || null : null}, + credentialsLevel = ${req.isGranted() ? req.body.credentialsLevel || null : null}, + credentialsName = ${req.isGranted() ? req.body.credentialsName || null : null}, card = NULL WHERE id = ${ids[0]} `);