예제 #1
0
	def _post(self):
		self.view['errors'] = {}
		if self._validate():
			solution = Solution(title=self._post['title'],body=self._post['body'],author=Roster.findByJid(self.session['auth']['jid']),language=int(self._post['language']))
			solution.put()
			super(Controller, self).redirect('/solutions/%s' % (solution.key().id()))
		self.view['post'] = self._post
예제 #2
0
	def _get(self):
		self.view['solution_list'] = []
		solutions  = Solution.all()
		solutions.order('-__key__')
		solutions = solutions.fetch(50)
		if len(solutions) > 0:
			for i in solutions:
				self.view['solution_list'].append({
					'id' : i.key().id(),
					'title' : i.title
				})
예제 #3
0
	def _get(self):
		id = int(self.request.url.split('/')[-1])
		self.view['solution_id'] = id
		self.view['solution'] = {}
		if id > 0:
			solution = Solution.get_by_id(id)
			if solution != None:
				self.view['solution'] = {
					'title':solution.title,
					'body':solution.body,
					'created':solution.created,
					'jid':solution.author.jid,
					'language':solution.language
				}
				return True
		super(Controller, self).redirect('/solutions')
		return False