コード例 #1
0
    def post(self):
        contest_dict = contest.get_contest_dict_from_request(self.request)
        parsed_time = time.strptime(contest_dict['time'], "%H:%M")
        date_and_time = datetime.datetime(
            year=int(contest_dict["year"]),
            month=list(calendar.month_name).index(contest_dict["month"]),
            day=int(contest_dict["day"]),
            hour=parsed_time.tm_hour,
            minute=parsed_time.tm_min)
        timezone = pytz.timezone(contest_dict["time_zone"])
        date_and_time = timezone.localize(date_and_time)
        contest_dict["date_and_time"] = date_and_time

        contest_dict["full_name"] = contest_dict["full_name"].replace(
            '\n', ' ')

        cont = None
        contest_id = self.request.get("id")
        if contest_id:

            cont = contest.get_contest_by_id(contest_id)
            for prop in cont.properties():
                setattr(cont, prop, contest_dict[prop])
            if not cont:
                self.redirect('\error?message=No contest with given id')
                return
        else:
            contest_dict["full_name"] = cgi.escape(contest_dict["full_name"])
            contest_dict["short_name"] = cgi.escape(contest_dict["short_name"])
            contest_dict["info"] = cgi.escape(contest_dict["info"])
            cont = Contest(parent=contest.PARENT_KEY, **contest_dict)

        cont.put()

        self.redirect('/')
コード例 #2
0
ファイル: edit_contest.py プロジェクト: rizar/win-them-all
    def post(self):
        contest_dict = contest.get_contest_dict_from_request(self.request)
        parsed_time = time.strptime(contest_dict['time'], "%H:%M")
        date_and_time = datetime.datetime(year = int(contest_dict["year"]),
                                          month = list(calendar.month_name).index(contest_dict["month"]),
                                          day = int(contest_dict["day"]),
                                          hour = parsed_time.tm_hour,
                                          minute = parsed_time.tm_min)
        timezone = pytz.timezone(contest_dict["time_zone"])
        date_and_time = timezone.localize(date_and_time)
        contest_dict["date_and_time"] = date_and_time

        contest_dict["full_name"] = contest_dict["full_name"].replace('\n', ' ')

        cont = None
        contest_id = self.request.get("id")
        if contest_id:

            cont = contest.get_contest_by_id(contest_id)
            for prop in cont.properties():
                setattr(cont, prop, contest_dict[prop])
            if not cont:
                self.redirect('\error?message=No contest with given id')
                return
        else:
            contest_dict["full_name"] = cgi.escape(contest_dict["full_name"])
            contest_dict["short_name"] = cgi.escape(contest_dict["short_name"])
            contest_dict["info"] = cgi.escape(contest_dict["info"])
            cont = Contest(parent = contest.PARENT_KEY, **contest_dict)

        cont.put()

        self.redirect('/')