series viewable flag

master
Kit Kasune 1 year ago
parent 351d7e7431
commit 77946475a1
  1. 8
      api/ani/v1/routes/series/add.js
  2. 2
      api/ani/v1/routes/series/edits.js
  3. 3
      db/ani/series.js

@ -106,7 +106,7 @@ module.exports = (app, router) => {
}) })
.get(app.auth.tokenPass, app.auth.permsPass('series-approve'), async (req, res, next) => { .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 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();} if (req.params.id.toLowerCase() === 'queue') {return next();}
return res.status(400).send("A series with that ID doesn't exist!"); 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} 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 }; /**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)
*/

@ -53,6 +53,8 @@ module.exports = (app, router) => {
].forEach(field => edits.stringWrap(field[0], field[1])); ].forEach(field => edits.stringWrap(field[0], field[1]));
//router.use('/:id/altnames', app.auth.tokenPass, app.auth.permsPass('series-approve')) //router.use('/:id/altnames', app.auth.tokenPass, app.auth.permsPass('series-approve'))
}; };

@ -12,13 +12,14 @@ module.exports = (connection) => connection.model('series', new Schema({
action: String action: String
}], default: []}, }], default: []},
completed: {type: Boolean, default: false}, //SUBMISSION completed 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: <uid>} approved: {type: Schema.Types.Mixed, default: false}, //boolean or {approved: Boolean, by: <uid>}
submitted: Schema.Types.Mixed, //can be false or a string with the ID of the submitter, //!REQ submitted: Schema.Types.Mixed, //can be false or a string with the ID of the submitter, //!REQ
hidden: {type: Boolean, default: false}, hidden: {type: Boolean, default: false},
reviewFlags: {type: [{ reviewFlags: {type: [{
by: String, by: String,
reason: 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 }, //!REQ
name: {type: String, required: true, maxLength: 150}, //!REQ name: {type: String, required: true, maxLength: 150}, //!REQ

Loading…
Cancel
Save