From 77946475a1fc525d2ad47714d38c0a6e04694406 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Thu, 6 Jul 2023 04:26:30 -0400 Subject: [PATCH] series viewable flag --- api/ani/v1/routes/series/add.js | 8 ++++++-- api/ani/v1/routes/series/edits.js | 2 ++ db/ani/series.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/ani/v1/routes/series/add.js b/api/ani/v1/routes/series/add.js index cac8092..8f579bb 100644 --- a/api/ani/v1/routes/series/add.js +++ b/api/ani/v1/routes/series/add.js @@ -106,7 +106,7 @@ module.exports = (app, router) => { }) .get(app.auth.tokenPass, app.auth.permsPass('series-approve'), async (req, res, next) => { const series = req.params.id.match(/^\d+$/) ? await Anime.findOne({numericalId: req.params.id.toLowerCase()}) : await Anime.findOne({id: req.params.id.toLowerCase()}); //TODO make sure all ID calls are lowercased - if (!series || (series && !series.meta.completed && req.unauthorized)) { + if (!series || (series && !series.meta.completed && !series.meta.viewable && req.unauthorized)) { if (req.params.id.toLowerCase() === 'queue') {return next();} return res.status(400).send("A series with that ID doesn't exist!"); } @@ -117,4 +117,8 @@ module.exports = (app, router) => { meta: {completed: series.meta.completed, creator: series.meta.creator, locked: series.meta.locked} }); }); -}; //TODO check that series can be submitted but not completed. consider making this not allowed, or figure out what to do about the fact that editing all the fields is a complete pain \ No newline at end of file +}; /**TODO check that series can be submitted but not completed. consider making this not allowed, or figure out what to do about the fact that editing all the fields is a complete pain + * a series must have an ID, name, romaji, and genres listed to be submitted + * series can be submitted with those but making a series public requires more fields + * for special cases, a series can be marked by an admin as viewable (confirmed second season or series, etc) +*/ \ No newline at end of file diff --git a/api/ani/v1/routes/series/edits.js b/api/ani/v1/routes/series/edits.js index c57959a..d9de626 100644 --- a/api/ani/v1/routes/series/edits.js +++ b/api/ani/v1/routes/series/edits.js @@ -53,6 +53,8 @@ module.exports = (app, router) => { ].forEach(field => edits.stringWrap(field[0], field[1])); + + //router.use('/:id/altnames', app.auth.tokenPass, app.auth.permsPass('series-approve')) }; \ No newline at end of file diff --git a/db/ani/series.js b/db/ani/series.js index 0fddfaa..c420f50 100644 --- a/db/ani/series.js +++ b/db/ani/series.js @@ -12,13 +12,14 @@ module.exports = (connection) => connection.model('series', new Schema({ action: String }], default: []}, completed: {type: Boolean, default: false}, //SUBMISSION completed + viewable: {type: Boolean, default: false}, // exists solely as completion override. WILL NOT make a completed series invisible if false approved: {type: Schema.Types.Mixed, default: false}, //boolean or {approved: Boolean, by: } submitted: Schema.Types.Mixed, //can be false or a string with the ID of the submitter, //!REQ hidden: {type: Boolean, default: false}, reviewFlags: {type: [{ by: String, reason: String, - }], default: []} + }], default: []} // notes left by an admin or curator about work that needs to be done on a series for it to be approved }, //!REQ name: {type: String, required: true, maxLength: 150}, //!REQ