Exemple #1
0
	def get(self, username):

		response = {}

		self.username = username
		self.answered_ids = None

		response['answered_questions'] = [utils.question_to_dict(q) for q in self.getAnsweredQuestions()]
		response['unanswered_questions'] = [utils.question_to_dict(q) for q in self.getUnansweredQuestions()]

		self.returnJSON(200, response)
Exemple #2
0
    def get(self, username):

        response = {}

        self.username = username
        self.answered_ids = None

        response['answered_questions'] = [
            utils.question_to_dict(q) for q in self.getAnsweredQuestions()
        ]
        response['unanswered_questions'] = [
            utils.question_to_dict(q) for q in self.getUnansweredQuestions()
        ]

        self.returnJSON(200, response)
Exemple #3
0
    def get(self, slug):

        response = {}
        try:
            mp = MP.all().filter('slug =', slug)[0]
            response['mp'] = utils.mp_to_dict(mp)
        except:
            self.returnJSON(404, response)
            return

        self.query = MPVote.all().filter('mp_slug =', slug)
        self.filterQueryOnParam('question')
        self.filterQueryOnParam('selection')

        response['votes'] = []
        for vote in self.query:
            d = db.to_dict(vote)
            d['question'] = utils.question_to_dict(vote.parent())
            del d['mp_party']
            del d['mp_constituency']
            del d['mp_slug']
            del d['mp_name']
            response['votes'].append(d)
        response['total'] = len(response['votes'])

        self.returnJSON(200, response)
Exemple #4
0
	def get(self, slug):

		response = {}
		try:
			mp = MP.all().filter('slug =', slug)[0]
			response['mp'] = utils.mp_to_dict(mp)
		except:
			self.returnJSON(404, response)
			return

		self.query = MPVote.all().filter('mp_slug =', slug)
		self.filterQueryOnParam('question')
		self.filterQueryOnParam('selection')

		response['votes'] = []
		for vote in self.query:
			d = db.to_dict(vote)
			d['question'] = utils.question_to_dict(vote.parent())
			del d['mp_party']
			del d['mp_constituency']
			del d['mp_slug']
			del d['mp_name']
			response['votes'].append(d)
		response['total'] = len(response['votes'])

		self.returnJSON(200, response)
Exemple #5
0
	def get(self):

		response = {}

		self.query = Question.all()
		response['total'] = self.query.count()
		response = self.addPagingFilters(response)
		response['questions'] = [utils.question_to_dict(q) for q in self.query]

		self.returnJSON(200, response)
Exemple #6
0
    def get(self):

        response = {}

        self.query = Question.all()
        response['total'] = self.query.count()
        response = self.addPagingFilters(response)
        response['questions'] = [utils.question_to_dict(q) for q in self.query]

        self.returnJSON(200, response)
Exemple #7
0
	def get(self, username):
		response = {}

		self.username = username
		self.answered_ids = None

		questions = self.getUnansweredQuestions()
		response['total'] = len(questions)
		response['questions'] = [utils.question_to_dict(q) for q in questions]

		self.returnJSON(200, response)
Exemple #8
0
    def get(self, username):
        response = {}

        self.username = username
        self.answered_ids = None

        questions = self.getUnansweredQuestions()
        response['total'] = len(questions)
        response['questions'] = [utils.question_to_dict(q) for q in questions]

        self.returnJSON(200, response)
Exemple #9
0
	def get(self, question_key):

		response = {}

		try:
			question = Question.get(question_key)
			response['question'] = utils.question_to_dict(question)
		except:
			response['error'] = 'Cannot find question'
			self.returnJSON(404, response)

		self.returnJSON(200, response)
Exemple #10
0
    def get(self, question_key):

        response = {}

        try:
            question = Question.get(question_key)
            response['question'] = utils.question_to_dict(question)
        except:
            response['error'] = 'Cannot find question'
            self.returnJSON(404, response)

        self.returnJSON(200, response)