/**
 * Kanso document types to export
 */

var Type = require('couchtypes/types').Type,
    fields = require('couchtypes/fields'),
    widgets = require('couchtypes/widgets'),
    permissions = require('couchtypes/permissions');

exports.page = new Type('page', {
    permissions: {
        add: permissions.hasRole('wikieditor'),
        update: permissions.hasRole('wikieditor'),
        remove: permissions.hasRole('wikieditor')
    },
    fields: {
        _id: fields.string({
            validators: [function(doc, val, raw) {
                if (!permissions.hasRole('_admin')) {
                    // user is not admin, check page _id
                    var restricted = ["TAPIRWIKISETTINGS", "NewPage"];
                    for (i in restricted) {
                        if (val == restricted[i]) throw new Error("Restricted _id: " + restricted[i] + ". Not allowed to modify.");
                    }
                }
            }]
        }),
        body: fields.string(),
        edited_by: fields.string(),
        edited_on: fields.string()
    }
});

@@ -220,18 +220,49 @@
 ssions')
+,%0A    editorRole = 'wikieditor'
 ;%0A
-
 %0Aexports
@@ -336,36 +336,34 @@
 ons.hasRole(
-'wiki
 editor
-'
+Role
 ),%0A        u
@@ -389,28 +389,26 @@
 hasRole(
-'wiki
 editor
-'
+Role
 ),%0A     
@@ -438,28 +438,26 @@
 hasRole(
-'wiki
 editor
-'
+Role
 )%0A    %7D,

use var editorRole