def post(self): email = self.request.get('user') inputTitle = self.request.get('inputTitle') inputDescription = self.request.get('inputDescription') domain = self.request.get('domain') duree_plan = self.request.get('duree_plan') u_exercices = self.request.get('exercices') str_exercices = unicodedata.normalize('NFKD', u_exercices).encode('ascii','ignore') exercices = json.loads(str_exercices) plan = PlanEntrainement( user=str(email), title=inputTitle, description=inputDescription, domain=domain, duree=int(duree_plan)) e_key = plan.put() for ex in exercices: exercice = Exercice(parent=e_key) exercice.titleDescription = str(ex.get('titleDescription').encode('utf-8')) exercice.exerciceDescription = str(ex.get('exerciceDescription').encode('utf-8')) exercice.duree = int(ex.get('duree')) exercice.repetition = int(ex.get('repetition')) exercice.put()
def get(self): data = cgi.FieldStorage().getvalue('data') user = users.get_current_user() if user: url = users.create_logout_url('/') if data: data = json.load(data) plan = PlanEntrainement.get_by_id(data.get('id')) exercices = Exercice.get_exercices_from_ancestor(plan) self.response.write(globales.result_detail.render(user=user, url=url, plan=plan.title,exercices=exercices)) else: self.response.write(globales.search.render(user=user, url=url)) else: url = users.create_login_url('/') self.response.write(globales.search.render(user=None, url=url))