source: Dev/branches/rest-dojo-ui/client/config/docs.js @ 414

Last change on this file since 414 was 414, checked in by hendrikvanantwerpen, 12 years ago

Small issues for db name, widgets, startup.

Don't start application when database is not configured correctly.
Refactored edit widgets to use DefaultEdit?.
Fixed bug in getItems of Lists.
Renamed database to 'qed'.

File size: 4.2 KB
Line 
1define([],function(){
2    return {
3        "_users/qed_admin": {
4            __configAction: "ignore",
5            _id: "org.couchdb.user:qed_admin",
6            name: "qed_admin",
7            password: "Welkom01",
8            roles: [ "qed_admin" ],
9            type: "user"
10        },
11        "qed/_security": {
12            __configAction: "ignore",
13            admins: {
14                names: [],
15                roles: ["qed_admin"]
16            },
17            readers: {
18                names: [],
19                roles: ["qed_user"]
20            }
21        },
22        "qed/_design/default": {
23            __configAction: "replace",
24            _id: "_design/default",
25            language: "javascript",
26            validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) {
27                if ( oldDoc && oldDoc.publicationDate ) { throw({forbidden:'Published documents cannot be modified.'}); }
28                if ( !newDoc._deleted && !newDoc.type ) { throw({forbidden:'Documents must have a type field.'}); }
29            },
30            views: {
31                by_type: {
32                    map: function(doc){
33                        emit(doc.type, doc);
34                    }
35                }
36            }
37        },
38        "qed/_design/questions": {
39            __configAction: "replace",
40            _id: "_design/questions",
41            language: "javascript",
42            validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) {
43                if( newDoc._deleted || newDoc.type!=='Question' ){ return; }
44                if( !newDoc.code ){ throw({forbidden:'Question must have a code field.'});}
45            },
46            views: {
47                all: {
48                    map: function(doc){
49                        if ( doc.type !== 'Question' ) { return; }
50                        if ( doc.categories && doc.categories.length > 0 ) {
51                            for ( var i = 0; i < doc.categories.length; i++ ) {
52                                emit([doc.categories[i],doc.topic||null],1);
53                            }
54                        } else {
55                            emit([null,null],1);
56                        }
57                    },
58                    reduce: function(keys,values){ return sum(values); }
59                },
60                published: {
61                    map: function(doc){
62                        if ( doc.type!=='Question' || !doc.publicationDate ) { return; }
63                        if ( doc.categories && doc.categories.length > 0 ) {
64                            for ( var i = 0; i < doc.categories.length; i++ ) {
65                                emit([doc.categories[i],doc.topic||null],1);
66                            }
67                        } else {
68                            emit([null,null],1);
69                        }
70                    },
71                    reduce: function(keys,values){ return sum(values); }
72                },
73                all_topics: {
74                    map: function(doc){
75                        if( doc.type !== 'Question' ){ return; }
76                        emit(doc.topic);
77                    },
78                    reduce: function(key, values, rereduce) { return null; }
79                },
80                published_topics: {
81                    map: function(doc){
82                        if ( doc.type !== 'Question' || !doc.publicationDate ) { return; }
83                        emit(doc.topic);
84                    },
85                    reduce: function(key, values, rereduce) { return null; }
86                }
87            }
88        },
89        "qed/_design/surveys": {
90            __configAction: "replace",
91            _id: "_design/surveys",
92            language: "javascript",
93            views: {
94                drafts: {
95                    map: function(doc){
96                        if ( doc.type !== 'Survey' || doc.publicationDate ) { return; }
97                        emit(doc._id,doc);
98                    }
99                },
100                published: {
101                    map: function(doc){
102                        if ( doc.type !== 'Survey' || !doc.publicationDate ) { return; }
103                        emit(doc._id,doc);
104                    }
105                }
106            }
107        }
108    };
109});
Note: See TracBrowser for help on using the repository browser.