Index: Dev/trunk/src/client/qed-client/pages/response.js
===================================================================
--- Dev/trunk/src/client/qed-client/pages/response.js	(revision 477)
+++ Dev/trunk/src/client/qed-client/pages/response.js	(revision 478)
@@ -63,4 +63,5 @@
             this.submitButton.set('disabled',false);
             this.continueButton.set('disabled',false);
+            this.cancelButton.set('disabled',false);
             this.surveyWidget.set('disabled', false);
         },
@@ -68,4 +69,5 @@
             this.submitButton.set('disabled',true);
             this.continueButton.set('disabled',true);
+            this.cancelButton.set('disabled',true);
             this.surveyWidget.set('disabled', true);
         },
@@ -80,7 +82,8 @@
                 data:json.toJson(this.response),
                 headers:{"Content-Type": "application/json"}
-            }).then(function(){
+            }).then(lang.hitch(this,function(res){
+                this.response._rev = res.rev;
                 Content.notify("Your response is saved.");
-            }, function(err){
+            }), function(err){
                 Content.notify(err,'error');
             });
@@ -104,4 +107,21 @@
             return false;
         },
+        _onCancel: function(e) {
+            this._disableSubmit();
+            this.surveyWidget.destroy();
+            request('/api/responses/'+store.getIdentity(this.response)+'?rev='+store.getRevision(this.response),{
+                method: 'DELETE',
+                handleAs:'json',
+                data:json.toJson(this.response),
+                headers:{"Content-Type": "application/json"}
+            }).then(lang.hitch(this,function(res){
+                this._showInfo("<div>Your response has been deleted, no answers have been saved.</div>");
+                Content.notify("Your response is deleted.");
+            }), function(err){
+                Content.notify(err,'error');
+            });
+            if ( e ) { event.stop(e); }
+            return false;
+        },
         _ignoreEvent: function(e) {
             if ( e ) { event.stop(e); }
Index: Dev/trunk/src/client/qed-client/pages/templates/response.html
===================================================================
--- Dev/trunk/src/client/qed-client/pages/templates/response.html	(revision 477)
+++ Dev/trunk/src/client/qed-client/pages/templates/response.html	(revision 478)
@@ -29,5 +29,10 @@
                 data-dojo-attach-point="continueButton"
                 data-dojo-attach-event="onClick:_onContinueLater">
-            Continue later</button>
+            Save & Continue later</button>
+        <button data-dojo-type="dijit/form/Button"
+                type="button"
+                data-dojo-attach-point="cancelButton"
+                data-dojo-attach-event="onClick:_onCancel">
+            Cancel & Delete</button>
     </div>
 
Index: Dev/trunk/src/client/qed-client/store.js
===================================================================
--- Dev/trunk/src/client/qed-client/store.js	(revision 477)
+++ Dev/trunk/src/client/qed-client/store.js	(revision 478)
@@ -10,5 +10,5 @@
     
     var couchStore = new CouchStore({
-        target: 'api/data/',
+        target: '/data/',
         request: request /*,
         validate: function(object) {
Index: Dev/trunk/src/server/app.js
===================================================================
--- Dev/trunk/src/server/app.js	(revision 477)
+++ Dev/trunk/src/server/app.js	(revision 478)
@@ -48,7 +48,7 @@
 
     // cookies and session
-    app.use('/api',express.bodyParser());
     app.use(express.cookieParser());
     app.use(express.session({ secret: "quasi experimental design" }));
+    app.use('/api',express.bodyParser());
 
     // passport
@@ -77,4 +77,7 @@
     });
 
+    // data is proxied to couch
+    app.use('/data', ensureAuthenticated);
+    app.use('/data', proxy(settings.couchDbURL));
 
     // post to this url to login
@@ -99,12 +102,4 @@
         });
 
-    // expose everything needed to fill in responses
-    // FIXME : this needs more security, now you can guess ids
-    //         and get actual survey and response data!
-    app.get(
-        '/live',
-        function(req,res){
-            res.redirect('/response.html#!/55704d6a84194c2d7ba9bec93c000e75');
-        });
     app.get(
         '/api/surveyRuns/:id',
@@ -155,9 +150,16 @@
             });
         });
+    app.delete(
+        '/api/responses/:id',
+        function(req,res){
+            var id = req.params.id;
+            var rev = req.query.rev;
+            couch.delete(id,rev).then(function(result){
+                res.send(200, result);
+            }, function(error){
+                res.send(500, error);
+            });
+        });
     
-    // data is proxied to couch
-    app.use('/api/data', ensureAuthenticated);
-    app.use('/api/data', proxy(settings.couchDbURL));
-
     // generate CSV download of responses
     app.get(
@@ -224,5 +226,5 @@
 }
 
-function writeObjectsToCSVStream(objects, stream) {
+function writeObjectsToCSVStream(objects, stream, prelude) {
     var keys = _.chain(objects)
                 .map(_.keys)
@@ -235,4 +237,9 @@
     });
     var writer = new CSV.CsvWriter(stream);
+    if ( prelude ) {
+        _.forEach(prelude, function(val,key){
+            writer.writeRecord([key,val]);
+        });
+    }
     writer.writeRecord(keys);
     _.forEach(objects, function(obj){
Index: Dev/trunk/src/server/util/couch.coffee
===================================================================
--- Dev/trunk/src/server/util/couch.coffee	(revision 477)
+++ Dev/trunk/src/server/util/couch.coffee	(revision 478)
@@ -15,4 +15,7 @@
         url = "#{@url}/#{id}"
         couchRequest 'PUT', url, doc
+    delete: (id, rev) ->
+        url = "#{@url}/#{id}?rev=#{rev}"
+        couchRequest 'DELETE', url
 
 normalizeURL = (url) ->
