var router = require('express').Router({ mergeParams: true });
var getSubmissionsList = require('./controllers/get-submissionslist');
var getJsonSubmissions = require('./controllers/get-json-submissions');
var getCsvSubmissions = require('./controllers/get-csv-submissions');
var getOsmSubmissions = require('./controllers/get-osm-submissions');
var getManifest = require('./controllers/get-manifest');
var getSubmissionAttachments = require('./controllers/get-submission-attachments');
var patchSubmissions = require('./controllers/patch-submissions');
var uploadForm = require('./controllers/upload-form');
var submitChangesets = require('./controllers/submit-changesets');

/**
 * Aggregate End Points
 */
var adminDVPermission = require('permission')(['admin', 'data-viewer']);
var adminPermission = require('permission')(['admin']);

router.route('/submissions').get(getSubmissionsList);
router.route('/submissions/:formName.json').get(adminDVPermission, getJsonSubmissions);
router.route('/submissions/:formName.csv').get(adminDVPermission, getCsvSubmissions);
router.route('/submissions/:formName.osm')
                .get(adminDVPermission, getOsmSubmissions)
                .patch(patchSubmissions);
router.route('/submissions/:formName.zip').get(adminDVPermission, getSubmissionAttachments);

/**
 * XLSForm Upload Endpoint
 */
router.route('/upload-form').post(adminPermission, uploadForm);

router.route('/manifest/:formName.xml').get(getManifest);

/**
 * Creates changesets for submissions and submits to
 * an OSM Editing API
 */
router.route('/submit-changesets/:formName')
                .get(submitChangesets)
                .put(submitChangesets);

module.exports = router;

@@ -1606,16 +1606,33 @@
    .get(
+adminPermission, 
 submitCh
@@ -1662,16 +1662,33 @@
    .put(
+adminPermission, 
 submitCh

add admin permission to submit-changesets view