def _process_request(self, request, event_key):
        rankings = JSONRankingsParser.parse(request.body)

        event_details = EventDetails(id=event_key, rankings=rankings)
        if event_details.year >= 2017:  # TODO: Temporary fix. Should directly parse request into rankings2
            event_details.rankings2 = RankingsHelper.convert_rankings(
                event_details)
        EventDetailsManipulator.createOrUpdate(event_details)

        self.response.out.write(
            json.dumps({'Success': "Rankings successfully updated"}))
    def _process_request(self, request, event_key):
        rankings = JSONRankingsParser.parse(request.body)

        event_details = EventDetails(
            id=event_key,
            rankings=rankings
        )
        if event_details.year >= 2017:  # TODO: Temporary fix. Should directly parse request into rankings2
            event_details.rankings2 = RankingsHelper.convert_rankings(event_details)
        EventDetailsManipulator.createOrUpdate(event_details)

        self.response.out.write(json.dumps({'Success': "Rankings successfully updated"}))
  def get(self, year):
    self._require_admin()

    event_keys = Event.query(Event.year==int(year)).fetch(keys_only=True)
    event_details = ndb.get_multi([ndb.Key(EventDetails, key.id()) for key in event_keys])
    updated = []
    for event_detail in event_details:
      if event_detail:
        logging.info(event_detail.key.id())
        event_detail.rankings2 = RankingsHelper.convert_rankings(event_detail)
        updated.append(event_detail)
    EventDetailsManipulator.createOrUpdate(updated)

    self.response.out.write("DONE")