def post_competition(self): """Reads common info about competition and statistic flags from post-request and fills template's values""" try: errors = [] start_date = self.request.POST['dateStartNew'] #if start_date >= datetime.now(): # TODO: error because start_date is string not datetime object. Convert string to date # pass finish_date = self.request.POST['dateFinishNew'] #if finish_date >= datetime.now(): # pass#errors.append('Finish date in the past') comp_name = self.request.POST['nameCompNew'] d_count = int(self.request.POST['dayCount']) show_places = self.request.POST['writePlaces'] show_map = self.request.POST['showMap'] stat_day = read_checkbox_post(self, 'statistic0') #TODO: fix statistic stat_sex = read_checkbox_post(self, 'statistic1') stat_qual = read_checkbox_post(self, 'statistic2') except KeyError: errors.append('Key error at request') competition = Competition(name=comp_name, d_start=date_to_python(start_date), d_finish=date_to_python(finish_date), days_count=d_count)#, statistic=[stat_day, stat_sex, stat_qual]) competition.put() temp_values = {'start': start_date, 'finish': finish_date, 'name': comp_name, 'show_places': show_places, 'show_map': show_map, 'days_count': range(1, int(d_count) + 1)} return [competition, temp_values, errors]