Changeset 497 for Dev


Ignore:
Timestamp:
03/10/14 01:33:18 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Better names for db backup and sync scripts.
  • Added SurveyRun? deletion in UI and prevent on server when a run has replies.
Location:
Dev/trunk
Files:
4 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/deploy.sh

    r476 r497  
    11#!/bin/sh
    22
    3 DEPLOYURL=git@heroku.com:quod-erat.git
    4 DEPLOYDIR=quod-erat.git
     3. ./env.sh
     4
    55RELBUILDDIR=../build
    66
  • Dev/trunk/src/client/qed-client/pages/surveys.js

    r490 r497  
    5959        _onRunDetails: function(surveyRun) {
    6060            Router.go(surveyRuns.getObjectPath(surveyRun));
     61        },
     62        _onRunDelete: function(surveyRun) {
     63            surveyRuns.remove(surveyRun)
     64            .then(lang.hitch(this,function(){
     65                this.notify("SurveyRun successfully deleted.");
     66                this.refreshRuns();
     67            }),lang.hitch(this,function(err){
     68                this.notify(err.error,'error');
     69            }));
    6170        },
    6271        refresh: function() {
     
    145154                                label: 'Details',
    146155                                tooltip: 'Show details for this run',
    147                                 icon: 'Details'
     156                                icon: 'Edit'
     157                            }
     158                        },{
     159                            callback: lang.hitch(this,'_onRunDelete',surveyRun),
     160                            properties: {
     161                                label: 'Delete',
     162                                tooltip: 'Delete this run',
     163                                icon: 'Delete'
    148164                            }
    149165                        }]
  • Dev/trunk/src/server/app.js

    r496 r497  
    622622        ensureAuthenticated,
    623623        ensureMIME(JSON_MIME),
    624         makeDocDel_id('SurveyRun'));
     624        function(req,res) {
     625            var id = req.params.id;
     626            var doc = req.body;
     627            var rev = etags.parse(req.header('If-Match'))[0] || (doc && doc._rev);
     628            getResponsesBySurveyRunId(id)
     629            .handle({
     630                200: function(responses) {
     631                    if ( responses.length > 0 ) {
     632                        return new HTTPResult(403,{error:"Cannot delete run that has responses."});
     633                    } else {
     634                        return deleteDocument(id,rev);
     635                    }
     636                }
     637            }).handle(res.send.bind(res));
     638        });
    625639    app.get('/api/surveyRuns/:id/responses',
    626640        ensureAuthenticated,
Note: See TracChangeset for help on using the changeset viewer.