<commit_before>const express = require('express'),
      router = express.Router(),
      auth = require('../middleware/auth'),
      bodyParser = require('body-parser'),
      Review = require('../models/review/review'),
      Post = require('../models/post/post'),
      Distillery = require('../models/distillery/distillery'),
      DrinkType = require('../models/drink-type/drink-type'),
      Rarity = require('../models/rarity/rarity'),
      Region = require('../models/region/region');

router.use(bodyParser.urlencoded({ extended: false }));

// admin landing page, showing actions and user's items
router.get('/', auth.requireSession, auth.getCurrentUser, function (req, res, next) {
  return Promise.all([
      Review.list({
        limit: 5,
        filters: [{ field: 'author', value: res.locals.currentUser.id }]
      }),
      Post.list({
        limit: 5,
        filters: [{ field: 'author', value: res.locals.currentUser.id }]
      })
    ])
    .then(results => {
      // todo: move to template
      return res.render('../views/admin/index.twig', {
        reviews: results[0],
        posts: results[1],
        user: res.locals.currentUser
      });
    })
    .catch(next);
});


// list all reviews
router.get('/reviews', auth.requireSession, auth.getCurrentUser, function (req, res, next) {
  return res.send('list of reviews');
});


// new review
router.get('/reviews/new', auth.getCurrentUser, function (req, res, next) {
  return Promise.all([
      Review.list({ orderBy: 'title', order: 'ASC' }),
      Post.list({ orderBy: 'title', order: 'ASC' }),
      Distillery.list(),
      DrinkType.list(),
      Rarity.list(),
      Region.list()
    ])
    .then(results => {
      return res.render('../views/admin/review.twig', {
        reviews: results[0],
        posts: results[1],
        distilleries: results[2],
        drinkTypes: results[3],
        rarities: results[4],
        regions: results[5]
      });
    })
    .catch(next);
});
<commit_msg>Require login for edit screen again<commit_after>const express = require('express'),
      router = express.Router(),
      auth = require('../middleware/auth'),
      bodyParser = require('body-parser'),
      Review = require('../models/review/review'),
      Post = require('../models/post/post'),
      Distillery = require('../models/distillery/distillery'),
      DrinkType = require('../models/drink-type/drink-type'),
      Rarity = require('../models/rarity/rarity'),
      Region = require('../models/region/region');

router.use(bodyParser.urlencoded({ extended: false }));

// admin landing page, showing actions and user's items
router.get('/', auth.requireSession, auth.getCurrentUser, function (req, res, next) {
  return Promise.all([
      Review.list({
        limit: 5,
        filters: [{ field: 'author', value: res.locals.currentUser.id }]
      }),
      Post.list({
        limit: 5,
        filters: [{ field: 'author', value: res.locals.currentUser.id }]
      })
    ])
    .then(results => {
      // todo: move to template
      return res.render('../views/admin/index.twig', {
        reviews: results[0],
        posts: results[1],
        user: res.locals.currentUser
      });
    })
    .catch(next);
});


// list all reviews
router.get('/reviews', auth.requireSession, auth.getCurrentUser, function (req, res, next) {
  return res.send('list of reviews');
});


// new review
router.get('/reviews/new', auth.requireSession, auth.getCurrentUser, function (req, res, next) {
  return Promise.all([
      Review.list({ orderBy: 'title', order: 'ASC' }),
      Post.list({ orderBy: 'title', order: 'ASC' }),
      Distillery.list(),
      DrinkType.list(),
      Rarity.list(),
      Region.list()
    ])
    .then(results => {
      return res.render('../views/admin/review.twig', {
        reviews: results[0],
        posts: results[1],
        distilleries: results[2],
        drinkTypes: results[3],
        rarities: results[4],
        regions: results[5]
      });
    })
    .catch(next);
});

{'fraction_non_alphanumeric': 0.17779985100571144, 'fraction_numerical': 0.004966476285075739, 'mean_word_length': 2.6028622540250446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '72525', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1222, 'n_words': 256}