source: Dev/trunk/src/server/config/couchdb-design-docs.js @ 492

Last change on this file since 492 was 492, checked in by hendrikvanantwerpen, 11 years ago
  • Enable/disable buttons on content change.
  • One place to do date formatting, because it was going wrong again.
  • Serialize questions in survey properly.
  • _ComplexValueMixin consumes submit events, but does trigger outer forms if present.
  • Trigger dialog show/hide for login only after previous effect is finished.
  • Check that documents are actually valid, not just that validator returned a result.
  • Validate email and timestamp formats.
  • Prepared for live runs.
File size: 4.8 KB
Line 
1module.exports = {
2
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
12    "qed/schemaInfo": {
13        version: "2"
14    },
15
16    "qed/_security": {
17        __configAction: "ignore",
18        admins: {
19            names: [],
20            roles: ["qed_admin"]
21        },
22        readers: {
23            names: [],
24            roles: ["qed_user"]
25        }
26    },
27
28    "qed/_design/default": {
29        __configAction: "replace",
30        _id: "_design/default",
31        language: "javascript",
32        validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) {
33            if ( oldDoc && oldDoc.publicationDate ) {
34                throw({forbidden:'Published documents cannot be modified.'});
35            }
36        },
37        views: {
38            by_type: {
39                map: function(doc){
40                    emit(doc.type, doc);
41                }
42            },
43            typeless: {
44                map: function(doc){
45                    if ( !doc.type ) {
46                        emit(doc._id, doc);
47                    }
48                }
49            }
50        }
51    },
52
53    "qed/_design/questions": {
54        __configAction: "replace",
55        _id: "_design/questions",
56        language: "javascript",
57        views: {
58            all: {
59                map: function(doc){
60                    if ( doc.type !== 'Question' ) { return; }
61                    if ( doc.categories && doc.categories.length > 0 ) {
62                        for ( var i = 0; i < doc.categories.length; i++ ) {
63                            emit([doc.categories[i],doc.topic||"(default)"],1);
64                        }
65                    } else {
66                        emit(["(default)","(default)"],1);
67                    }
68                },
69                reduce: function(keys,values){ return sum(values); }
70            },
71            published: {
72                map: function(doc){
73                    if ( doc.type!=='Question' || !doc.publicationDate ) { return; }
74                    if ( doc.categories && doc.categories.length > 0 ) {
75                        for ( var i = 0; i < doc.categories.length; i++ ) {
76                            emit([doc.categories[i],doc.topic||"(default)"],1);
77                        }
78                    } else {
79                        emit(["(default)","(default)"],1);
80                    }
81                },
82                reduce: function(keys,values){ return sum(values); }
83            },
84            all_topics: {
85                map: function(doc){
86                    if( doc.type !== 'Question' ){ return; }
87                    emit(doc.topic||"(default)",1);
88                },
89                reduce: function(key, values, rereduce) { return sum(values); }
90            },
91            published_topics: {
92                map: function(doc){
93                    if ( doc.type !== 'Question' || !doc.publicationDate ) { return; }
94                    emit(doc.topic||"(default)",1);
95                },
96                reduce: function(key, values, rereduce) { return sum(values); }
97            },
98            by_code: {
99                map: function(doc){
100                    if ( doc.type !== 'Question' ) { return; }
101                    emit(doc.code,doc);
102                }
103            }
104        }
105    },
106
107    "qed/_design/surveys": {
108        __configAction: "replace",
109        _id: "_design/surveys",
110        language: "javascript",
111        views: {
112            drafts: {
113                map: function(doc){
114                    if ( doc.type !== 'Survey' || doc.publicationDate ) { return; }
115                    emit(doc._id,doc);
116                }
117            },
118            published: {
119                map: function(doc){
120                    if ( doc.type !== 'Survey' || !doc.publicationDate ) { return; }
121                    emit(doc._id,doc);
122                }
123            }
124        }
125    },
126
127    "qed/_design/surveyRuns": {
128        __configAction: "replace",
129        _id: "_design/surveys",
130        language: "javascript",
131        views: {
132            by_dates: {
133                map: function(doc){
134                    if ( doc.type !== 'SurveyRun' ) { return; }
135                    var startDate = doc.startDate || "";
136                    var endDate = doc.endDate || {};
137                    emit([startDate,endDate,doc.liveName||null],doc);
138                }
139            }
140        }
141    },
142
143    "qed/_design/responses": {
144        __configAction: "replace",
145        _id: "_design/responses",
146        language: "javascript",
147        views: {
148            by_surveyrun: {
149                map: function(doc){
150                    if ( doc.type !== 'Response' ) { return; }
151                    emit(doc.surveyRunId, doc);
152                }
153            }
154        }
155    }
156
157};
Note: See TracBrowser for help on using the repository browser.