Index: Dev/trunk/backup.sh
===================================================================
--- Dev/trunk/backup.sh	(revision 496)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#!/bin/sh
-
-CLOUDANT_URL=`cd quod-erat.git/; heroku config:get CLOUDANT_URL`
-curl http://localhost:5984/_replicate -H "Content-Type: application/json" -d "{\"source\":\"$CLOUDANT_URL/qed\", \"target\":\"qed-`date +'%Y%m%dt%H%M%S'`\", \"create_target\":true}"
Index: Dev/trunk/db-backup-cloud-to-dated-local.sh
===================================================================
--- Dev/trunk/db-backup-cloud-to-dated-local.sh	(revision 497)
+++ Dev/trunk/db-backup-cloud-to-dated-local.sh	(revision 497)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+. ./env.sh
+
+if [ -z "$CLOUDANT_URL" ]; then
+    echo "Cloudant URL is not defined in env.sh"
+    exit 1
+fi
+
+curl http://localhost:5984/_replicate -H "Content-Type: application/json" -d "{\"source\":\"$CLOUDANT_URL/qed\", \"target\":\"qed-`date +'%Y%m%dt%H%M%S'`\", \"create_target\":true}"
Index: Dev/trunk/db-pull-cloud-to-local.sh
===================================================================
--- Dev/trunk/db-pull-cloud-to-local.sh	(revision 497)
+++ Dev/trunk/db-pull-cloud-to-local.sh	(revision 497)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+. ./env.sh
+
+if [ -z "$CLOUDANT_URL" ]; then
+    echo "Cloudant URL is not defined in env.sh"
+    exit 1
+fi
+
+curl http://localhost:5984/_replicate -H "Content-Type: application/json" -d "{\"source\":\"$CLOUDANT_URL/qed\", \"target\":\"qed\"}"
Index: Dev/trunk/db-push-local-to-cloud.sh
===================================================================
--- Dev/trunk/db-push-local-to-cloud.sh	(revision 497)
+++ Dev/trunk/db-push-local-to-cloud.sh	(revision 497)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+. ./env.sh
+
+if [ -z "$CLOUDANT_URL" ]; then
+    echo "Cloudant URL is not defined in env.sh"
+    exit 1
+fi
+
+curl http://localhost:5984/_replicate -H "Content-Type: application/json" -d "{\"target\":\"$CLOUDANT_URL/qed\", \"source\":\"qed\"}"
Index: Dev/trunk/deploy.sh
===================================================================
--- Dev/trunk/deploy.sh	(revision 496)
+++ Dev/trunk/deploy.sh	(revision 497)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEPLOYURL=git@heroku.com:quod-erat.git
-DEPLOYDIR=quod-erat.git
+. ./env.sh
+
 RELBUILDDIR=../build
 
Index: Dev/trunk/env.sh
===================================================================
--- Dev/trunk/env.sh	(revision 497)
+++ Dev/trunk/env.sh	(revision 497)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+DEPLOYURL=git@heroku.com:quod-erat.git
+DEPLOYDIR=quod-erat.git
+if [ -d "$DEPLOYDIR" ]; then
+    CLOUDANT_URL=`cd $DEPLOYDIR; heroku config:get CLOUDANT_URL`
+fi
+export DEPLOYURL DEPLOYDIR CLOUDANT_URL
Index: Dev/trunk/src/client/qed-client/pages/surveys.js
===================================================================
--- Dev/trunk/src/client/qed-client/pages/surveys.js	(revision 496)
+++ Dev/trunk/src/client/qed-client/pages/surveys.js	(revision 497)
@@ -59,4 +59,13 @@
         _onRunDetails: function(surveyRun) {
             Router.go(surveyRuns.getObjectPath(surveyRun));
+        },
+        _onRunDelete: function(surveyRun) {
+            surveyRuns.remove(surveyRun)
+            .then(lang.hitch(this,function(){
+                this.notify("SurveyRun successfully deleted.");
+                this.refreshRuns();
+            }),lang.hitch(this,function(err){
+                this.notify(err.error,'error');
+            }));
         },
         refresh: function() {
@@ -145,5 +154,12 @@
                                 label: 'Details',
                                 tooltip: 'Show details for this run',
-                                icon: 'Details'
+                                icon: 'Edit'
+                            }
+                        },{
+                            callback: lang.hitch(this,'_onRunDelete',surveyRun),
+                            properties: {
+                                label: 'Delete',
+                                tooltip: 'Delete this run',
+                                icon: 'Delete'
                             }
                         }]
Index: Dev/trunk/src/server/app.js
===================================================================
--- Dev/trunk/src/server/app.js	(revision 496)
+++ Dev/trunk/src/server/app.js	(revision 497)
@@ -622,5 +622,19 @@
         ensureAuthenticated,
         ensureMIME(JSON_MIME),
-        makeDocDel_id('SurveyRun'));
+        function(req,res) {
+            var id = req.params.id;
+            var doc = req.body;
+            var rev = etags.parse(req.header('If-Match'))[0] || (doc && doc._rev);
+            getResponsesBySurveyRunId(id)
+            .handle({
+                200: function(responses) {
+                    if ( responses.length > 0 ) {
+                        return new HTTPResult(403,{error:"Cannot delete run that has responses."});
+                    } else {
+                        return deleteDocument(id,rev);
+                    }
+                }
+            }).handle(res.send.bind(res));
+        });
     app.get('/api/surveyRuns/:id/responses',
         ensureAuthenticated,
