コード例 #1
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
    def get(self, survey_id):
        pprint('surveyresponse get method')

        survey_respones = Surveymodel.get_sur_res_by_surveyid(survey_id)
        if survey_respones:
            return survey_respones
        else:
            return {"message": "Survey Response not found"}
コード例 #2
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
    def put(self):
        data = request.get_json()

        pprint('survey Update method')
        surveyindb = Surveymodel.find_by_surveyname(data['survey_name'])
        if surveyindb is None:
            return {"message": "Survey with that Name doesn't exist."}, 400

        survey_tobeupdated = Surveymodel.requestmapper(data)
        survey_tobeupdated._id = data['survey_id']
        survey_updated = survey_tobeupdated.save()

        if survey_updated:
            pprint(survey_updated._id)
            return {
                "message": "Survey updated successfully.",
                "survey_id": survey_updated._id
            }, 201
        else:
            return {"message": "Survey Not Created."}
コード例 #3
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
    def post(self):
        data = request.get_json()

        pprint('survey compare post method')
        surveyindb = Surveymodel.find_by_surveyname(data['survey_name'])
        if surveyindb:
            return {"message": "Survey with that Name already exists."}, 400

        survey_tobecreated = Surveymodel.requestmapper(data)

        survey = survey_tobecreated.save()

        if survey_tobecreated:
            pprint(survey_tobecreated._id)
            return {
                "message": "Survey created successfully.",
                "survey_id": survey_tobecreated._id
            }, 201
        else:
            return {"message": "Survey Not Created."}
コード例 #4
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
    def post(self):
        pprint('surveyresponse post method')
        data = request.get_json()

        if data['participant_id'] != 1 and Surveymodel.get_sur_res_by_part_id(
                data['survey_id'], data['participant_id']):
            return {
                "message":
                "Survey response for this Participant already exists."
            }, 208
        else:
            surveres_tobecreated = Surveymodel.surveyresmapper(data)
            surveyres = surveres_tobecreated.save()
            if surveyres:
                pprint(surveyres._id)
                return {
                    "message": "Survey Response Submitted successfully."
                }, 201
            else:
                return {"message": "Survey Response Not Submitted."}
コード例 #5
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
 def get(self, survey_id):
     surveyindb = Surveymodel.find_by_surveyid(survey_id)
     if surveyindb:
         return surveyindb
     else:
         return {"message": "No such Survey exists."}
コード例 #6
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
 def get(self, name):
     surveyindb = Surveymodel.find_by_surveyname(name)
     if surveyindb:
         return surveyindb
     else:
         return {"message": "No such Survey exists."}
コード例 #7
0
ファイル: survey.py プロジェクト: sandipsmenon/survey_apis
 def get(self, creator_id):
     surveysindb = Surveymodel.find_all_surveys_for_userid(creator_id)
     if surveysindb:
         return surveysindb
     else:
         return {"message": "No Surveys found."}