mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
Merge branch 'misc' into 'main'
Improvements See merge request PronounsPage/PronounsPage!405
This commit is contained in:
commit
8725637b38
@ -5,7 +5,7 @@ SECRET=changeMeOnProd!
|
||||
|
||||
STATS_FILE=%projectdir%/stats.json
|
||||
|
||||
MAILER_TRANSPORT=smtps://username:password@smtp.example.com/?pool=true
|
||||
MAILER_TRANSPORT=
|
||||
MAILER_FROM=test@example.com
|
||||
|
||||
TWITTER_KEY=
|
||||
|
@ -39,7 +39,10 @@
|
||||
<button class="btn btn-sm btn-outline-success" @click="acceptTranslationProposal(tp.id)">Accept</button>
|
||||
<button class="btn btn-sm btn-outline-danger" @click="rejectTranslationProposal(tp.id)">Reject</button>
|
||||
</template>
|
||||
<span v-else class="badge bg-success text-white">Approved</span>
|
||||
<template v-else>
|
||||
<span class="badge bg-success text-white">Approved</span>
|
||||
<button class="btn btm-sm btn-outline-danger" @click="unapproveTranslationProposal(tp.id)">Unapprove</button>
|
||||
</template>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -147,6 +150,14 @@ export default {
|
||||
await this.$post(`/translations/reject-proposal`, {id})
|
||||
this.translationProposals = this.translationProposals.filter(tp => tp.id !== id);
|
||||
},
|
||||
async unapproveTranslationProposal(id) {
|
||||
await this.$confirm('Do you want to unmark this translation proposal as approved?', 'danger');
|
||||
await this.$post(`/translations/unapprove-proposal`, {id});
|
||||
this.translationProposals = this.translationProposals.map(tp => {
|
||||
if (tp.id === id) { tp.status = 0; }
|
||||
return tp;
|
||||
});
|
||||
},
|
||||
async markTranslationProposalsDone() {
|
||||
await this.$confirm(`This will mark all approved translations as done and they'll disappear from here –
|
||||
but they'll only actually show up on production if they are added to the <code>translations.suml</code> file
|
||||
|
@ -25,7 +25,7 @@ router.post('/translations/propose', handleErrorAsync(async (req, res) => {
|
||||
await req.db.get(SQL`INSERT INTO translations (id, locale, tKey, tValue, status, author_id) VALUES (
|
||||
${ulid()}, ${global.config.locale},
|
||||
${tKey}, ${JSON.stringify(req.body.changes[tKey])},
|
||||
${req.isGranted('translations') ? TRANSLATION_STATUS.APPROVED : TRANSLATION_STATUS.AWAITING}, ${req.user.id}
|
||||
${TRANSLATION_STATUS.AWAITING}, ${req.user.id}
|
||||
)`);
|
||||
}
|
||||
|
||||
@ -102,6 +102,21 @@ router.post('/translations/accept-proposal', handleErrorAsync(async (req, res) =
|
||||
return res.json('OK');
|
||||
}));
|
||||
|
||||
router.post('/translations/unapprove-proposal', handleErrorAsync(async (req, res) => {
|
||||
if (!req.isGranted('translations')) {
|
||||
return res.status(401).json({error: 'Unauthorised'});
|
||||
}
|
||||
|
||||
await req.db.get(SQL`UPDATE translations SET status = ${TRANSLATION_STATUS.AWAITING} WHERE id = ${req.body.id}`)
|
||||
|
||||
await auditLog(req, 'translations/unapproved', {
|
||||
locale: global.config.locale,
|
||||
id: req.body.id,
|
||||
});
|
||||
|
||||
return res.json('OK');
|
||||
}));
|
||||
|
||||
|
||||
router.post('/translations/proposals-done', handleErrorAsync(async (req, res) => {
|
||||
if (!req.isGranted('translations')) {
|
||||
|
@ -12,7 +12,11 @@ const loadSuml = name => new Suml().parse(fs.readFileSync(`${__dirname}/../${nam
|
||||
const translations = loadSuml('data/translations');
|
||||
const fallbackTranslations = loadSuml('locale/_base/translations');
|
||||
|
||||
const transporter = nodemailer.createTransport(process.env.MAILER_TRANSPORT, {from: process.env.MAILER_FROM});
|
||||
let transport = process.env.MAILER_TRANSPORT;
|
||||
if (!transport && process.env.NODE_ENV === 'development') {
|
||||
transport = {streamTransport: true};
|
||||
}
|
||||
const transporter = nodemailer.createTransport(transport, {from: process.env.MAILER_FROM});
|
||||
|
||||
const sendEmail = (to, subject, text = undefined, html = undefined) => {
|
||||
transporter.sendMail({
|
||||
@ -20,7 +24,14 @@ const sendEmail = (to, subject, text = undefined, html = undefined) => {
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
}, function(err) { if (err) { console.error(err); } })
|
||||
}, function(err, info) {
|
||||
if (process.env.NODE_ENV === 'development' && info.message) {
|
||||
info.message.pipe(process.stdout);
|
||||
}
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
const findTranslation = (key) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user