Skip to content

Commit

Permalink
Merge branch 'devel' into api-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
manuGil authored Mar 27, 2024
2 parents c022200 + a864edd commit 9b56cb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion citizenvoice/tests/test_api_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setUpTestData(cls):
point_feature = PointFeature(geom='SRID=4326;POINT (0.0075149652548134 0.0322341867016535)', description='Test point', location=location_collection)
point_feature.save()


def test_get_non_expired_surveys(self):
print('=================================')
print(Survey.objects.all())
Expand Down
18 changes: 13 additions & 5 deletions frontend/stores/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { useUserStore } from './user';
import { useGlobalStore } from './global';
import setRequestConfig from './utils/setRequestConfig';
import { useSurveyStore } from './survey';
import { useAnswerStore } from './answer';

// const answer = useAnswerStore();

export const useStoreResponse = defineStore('response', {

Expand All @@ -17,11 +20,12 @@ export const useStoreResponse = defineStore('response', {
return {
responseData: {},
answers:
[
[
// expects and array of objects with the following structure
// {
// question_index: integer,
// body: text,
// locations: [list of locations],
// }
],

Expand Down Expand Up @@ -126,7 +130,7 @@ export const useStoreResponse = defineStore('response', {
// Clear all the answers
this.answers = []
},
async submitAnswer(response_url, question_url, answer_value) {
async submitAnswer(response_url, question_id, answer_value) { // TODO: must include locations in the answer
const user = useUserStore();
const global = useGlobalStore();
const csrftoken = user.getCookie('csrftoken');
Expand All @@ -141,10 +145,11 @@ export const useStoreResponse = defineStore('response', {
// pas the data for the new Response object as the request body

// TODO: have the repondent set to the logged in user

body: {
response: response_url,
question: question_url,
body: answer_value
question: question_id,
body: answer_value,
}
};
if (token) {
Expand All @@ -156,7 +161,10 @@ export const useStoreResponse = defineStore('response', {
if (response) {
console.log('response submitted //> ');
}

if (error) {
console.log('error in SubmitAnswer //> ', error);
}

}

// TODO: CONTINUE HERE
Expand Down

0 comments on commit 9b56cb2

Please sign in to comment.