<commit_before>var util = require('./util');
var Model = require('../models/model');
var model = new Model();
var Reservation = require('../models/reservations');
var reservationModel = new Reservation();
var logger = require('../models/logger');

exports.view = function(req, res) {
  if (req.user !== undefined) {
    util.registerContent('roomreservations');
    reservationModel.getEventsWithUser(req.user, function(userEvents, allEvents) {
      res.render('base.html', {
        user: req.user,
        permissions: req.permissions,
        userEvents: userEvents,
        allEvents: allEvents
      });
    });
  } else {
    res.redirect('/login');
  }
};

exports.edit = function(req, res) {
  if (req.user !== undefined) {
    reservationModel.reserve(req.user, req.body, function(result) {
      util.registerContent('roomreservations');
      reservationModel.getEventsWithUser(req.user, function(userEvents) {
        res.render('base.html', {
          user: req.user,
          permissions: req.permissions,
          success: result.success,
          error: result.error,
          userEvents: userEvents
        });
      });
    });
  } else {
    res.redirect('/login');
  }
};

exports.delete = function(req, res) {
  if (req.user !== undefined) {
    reservationModel.removeReservation(req.user, req.body.id, function(err) {
      res.json({'okay': !err});
    });
  } else {
    res.redirect('/login');
  }
};

exports.confirm = function(req, res) {
  if (req.user !== undefined) {
    if (req.permissions.EDIT_RESERVATIONS) {<commit_msg>Oops.<commit_after>var util = require('./util');
var Model = require('../models/model');
var model = new Model();
var Reservation = require('../models/reservations');
var reservationModel = new Reservation();
var logger = require('../models/logger');

exports.view = function(req, res) {
  if (req.user !== undefined) {
    util.registerContent('roomreservations');
    reservationModel.getEventsWithUser(req.user, function(userEvents, allEvents) {
      res.render('base.html', {
        user: req.user,
        permissions: req.permissions,
        userEvents: userEvents,
        allEvents: allEvents
      });
    });
  } else {
    res.redirect('/login');
  }
};

exports.edit = function(req, res) {
  if (req.user !== undefined) {
    reservationModel.reserve(req.user, req.body, function(result) {
      util.registerContent('roomreservations');
      reservationModel.getEventsWithUser(req.user, function(userEvents) {
        res.render('base.html', {
          user: req.user,
          permissions: req.permissions,
          success: result.success,
          error: result.error,
          userEvents: userEvents
        });
      });
    });
  } else {
    res.redirect('/login');
  }
};

exports.delete = function(req, res) {
  if (req.user !== undefined) {
    reservationModel.removeReservation(req.user, req.body.id, function(err) {
      res.json({'okay': !err});
    });
  } else {
    res.redirect('/login');
  }
};

exports.confirm = function(req, res) {
  if (req.user !== undefined) {
    if (req.permissions.EDITRESERVATIONS) {
{'fraction_non_alphanumeric': 0.16222293607452618, 'fraction_numerical': 0.0, 'mean_word_length': 2.9923076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5494439', 'n_tokens_mistral': 955, 'n_tokens_neox': 952, 'n_words': 174}