Ignore:
Timestamp:
08/06/13 01:48:17 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Quick hack to allow responding despite not being authenticated. Something like tokes need to be added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/pages/response.js

    r461 r477  
    99    "dojo/_base/declare",
    1010    "dojo/_base/event",
     11    "dojo/_base/json",
    1112    "dojo/_base/lang",
    1213    "dojo/promise/all",
     14    "dojo/request",
    1315    "dojo/when",
    1416    "require",
    1517    "dojo/text!./templates/response.html"
    16 ], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, lang, all, when, require, template) {
     18], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, json, lang, all, request, when, require, template) {
    1719    return declare([Page],{
    1820        contextRequire: require,
     
    3739                        this._enableSubmit();
    3840                    }
    39                 }), function() {
     41                }), lang.hitch(this,function() {
    4042                    this._showInfo("<div>The url seems to be incorrect, no survey found.</div>");
    41                 });
     43                }));
    4244            } else {
    4345                throw new Error("No valid uid or survey passed!");
     
    4547        },
    4648        _loadSurveyAndResponse: function(surveyRunId,responseId){
    47             return all([store.get(surveyRunId),store.get(responseId)])
     49            return all([request.get('/api/surveyRuns/'+surveyRunId,{handleAs:'json'}),
     50                        request.get('/api/responses/'+responseId,{handleAs:'json'})])
    4851            .then(lang.hitch(this,function(surveyAndResponse){
    4952                var surveyRun = surveyAndResponse[0];
     
    7376            var answers = this.surveyWidget.get('value');
    7477            this.response.answers = answers;
    75             return store.put(this.response).then(function(){
     78            return request.put('/api/responses/'+store.getIdentity(this.response),{
     79                handleAs:'json',
     80                data:json.toJson(this.response),
     81                headers:{"Content-Type": "application/json"}
     82            }).then(function(){
    7683                Content.notify("Your response is saved.");
    7784            }, function(err){
     
    8289            this.response.publicationDate = store.timestamp();
    8390            this._getAnswersAndSaveResponse()
    84             .then(function(){
     91            .then(lang.hitch(this,function(){
    8592                this._showInfo("<div>Thanks for filling in the survey. You cannot edit your answers anymore.</div>");
    8693                this._disableSubmit();
    87             });
     94            }));
    8895            if ( e ) { event.stop(e); }
    8996            return false;
Note: See TracChangeset for help on using the changeset viewer.