Exemplo n.º 1
0
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"),
                                           "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"),
                                         "%Y-%m-%d")

        district_key = self.request.get("event_district_key", None)

        event = Event(
            id=str(self.request.get("year")) +
            str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            event_type_enum=EventHelper.parseEventType(
                self.request.get("event_type_str")),
            district_key=ndb.Key(District,
                                 self.request.get("event_district_key"))
            if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=self.request.get("website"),
            year=int(self.request.get("year")),
            official={
                "true": True,
                "false": False
            }.get(self.request.get("official").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get(
                "rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(
                    self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json")))
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"), "%Y-%m-%d")

        event = Event(
            id=str(self.request.get("year")) + str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            event_type_enum=EventHelper.parseEventType(self.request.get("event_type_str")),
            location=self.request.get("location"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=self.request.get("website"),
            year=int(self.request.get("year")),
            official={"true": True, "false": False}.get(self.request.get("official").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            webcast_json=self.request.get("webcast_json"),
            rankings_json=self.request.get("rankings_json"),
        )
        event = EventManipulator.createOrUpdate(event)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
Exemplo n.º 3
0
    def post(self):
        if self.request.get("verdict") == "accept":
            webcast = dict()
            webcast["type"] = self.request.get("webcast_type")
            webcast["channel"] = self.request.get("webcast_channel")
            if self.request.get("webcast_file"):
                webcast["file"] = self.request.get("webcast_file")

            event = Event.get_by_id(self.request.get("event_key"))
            suggestion = Suggestion.get_by_id(
                int(self.request.get("suggestion_key")))

            EventWebcastAdder.add_webcast(event, webcast)
            MemcacheWebcastFlusher.flush()

            suggestion.review_state = Suggestion.REVIEW_ACCEPTED
            suggestion.reviewer = self.user_bundle.account.key
            suggestion.reviewer_at = datetime.datetime.now()
            suggestion.put()

            self.redirect(
                "/suggest/event/webcast/review?success=accept&event_key=%s" %
                event.key.id())
            return

        elif self.request.get("verdict") == "reject":
            suggestion = Suggestion.get_by_id(
                int(self.request.get("suggestion_key")))

            suggestion.review_state = Suggestion.REVIEW_REJECTED
            suggestion.reviewer = self.user_bundle.account.key
            suggestion.reviewer_at = datetime.datetime.now()
            suggestion.put()

            self.redirect("/suggest/event/webcast/review?success=reject")
            return

        elif self.request.get("verdict") == "reject_all":
            suggestion_keys = self.request.get("suggestion_keys").split(",")

            suggestions = [
                Suggestion.get_by_id(int(suggestion_key))
                for suggestion_key in suggestion_keys
            ]

            for suggestion in suggestions:
                event_key = suggestion.target_key
                suggestion.review_state = Suggestion.REVIEW_REJECTED
                suggestion.reviewer = self.user_bundle.account.key
                suggestion.reviewer_at = datetime.datetime.now()
                suggestion.put()

            self.redirect(
                "/suggest/event/webcast/review?success=reject_all&event_key=%s"
                % event_key)
            return

        self.redirect("/suggest/event/webcast/review")
Exemplo n.º 4
0
    def create_target_model(self, suggestion):
        webcast = dict()
        webcast["type"] = self.request.get("webcast_type")
        webcast["channel"] = self.request.get("webcast_channel")
        if self.request.get("webcast_file"):
            webcast["file"] = self.request.get("webcast_file")

        event = Event.get_by_id(self.request.get("event_key"))
        EventWebcastAdder.add_webcast(event, webcast)
        MemcacheWebcastFlusher.flush()
    def post(self):
        self._require_admin()

        if self.request.get("verdict") == "accept":
            webcast = dict()
            webcast["type"] = self.request.get("webcast_type")
            webcast["channel"] = self.request.get("webcast_channel")
            if self.request.get("webcast_file"):
                webcast["file"] = self.request.get("webcast_file")

            event = Event.get_by_id(self.request.get("event_key"))
            suggestion = Suggestion.get_by_id(int(self.request.get("suggestion_key")))

            EventWebcastAdder.add_webcast(event, webcast)
            MemcacheWebcastFlusher.flush()

            suggestion.review_state = Suggestion.REVIEW_ACCEPTED
            suggestion.reviewer = self.user_bundle.account.key
            suggestion.reviewer_at = datetime.datetime.now()
            suggestion.put()

            self.redirect("/admin/suggestions/event/webcast/review?success=accept&event_key=%s" % event.key.id())
            return

        elif self.request.get("verdict") == "reject":
            suggestion = Suggestion.get_by_id(int(self.request.get("suggestion_key")))

            suggestion.review_state = Suggestion.REVIEW_REJECTED
            suggestion.reviewer = self.user_bundle.account.key
            suggestion.reviewer_at = datetime.datetime.now()
            suggestion.put()

            self.redirect("/admin/suggestions/event/webcast/review?success=reject")
            return

        elif self.request.get("verdict") == "reject_all":
            suggestion_keys = self.request.get("suggestion_keys").split(",")

            suggestions = [Suggestion.get_by_id(int(suggestion_key)) for suggestion_key in suggestion_keys]

            for suggestion in suggestions:
                event_key = suggestion.target_key
                suggestion.review_state = Suggestion.REVIEW_REJECTED
                suggestion.reviewer = self.user_bundle.account.key
                suggestion.reviewer_at = datetime.datetime.now()
                suggestion.put()

            self.redirect("/admin/suggestions/event/webcast/review?success=reject_all&event_key=%s" % event_key)
            return


        self.redirect("/admin/suggestions/event/webcast/review")
Exemplo n.º 6
0
    def remove_webcast(cls, event, index, type, channel, file):
        webcasts = event.webcast
        if not webcasts or index >= len(webcasts):
            return

        webcast = webcasts[index]
        if type != webcast.get("type") or channel != webcast.get("channel") or file != webcast.get("file"):
            return

        webcasts.pop(index)
        event.webcast_json = json.dumps(webcasts)
        EventManipulator.createOrUpdate(event, auto_union=False)
        MemcacheWebcastFlusher.flushEvent(event.key_name)
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"), "%Y-%m-%d")

        district_key = self.request.get("event_district_key", None)

        event = Event(
            id=str(self.request.get("year")) + str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            event_type_enum=EventHelper.parseEventType(self.request.get("event_type_str")),
            district_key=ndb.Key(District, self.request.get("event_district_key")) if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=self.request.get("website"),
            year=int(self.request.get("year")),
            official={"true": True, "false": False}.get(self.request.get("official").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            playoff_type=int(self.request.get("playoff_type")),
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get("rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json"))
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
Exemplo n.º 8
0
    def remove_webcast(cls, event, index, type, channel, file):
        webcasts = event.webcast
        if not webcasts or index >= len(webcasts):
            return

        webcast = webcasts[index]
        if type != webcast.get("type") or channel != webcast.get(
                "channel") or file != webcast.get("file"):
            return

        webcasts.pop(index)
        event.webcast_json = json.dumps(webcasts)
        EventManipulator.createOrUpdate(event)
        MemcacheWebcastFlusher.flushEvent(event.key_name)
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"),
                                           "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"),
                                         "%Y-%m-%d")

        event = Event(
            id=str(self.request.get("year")) +
            str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            event_type_enum=EventHelper.parseEventType(
                self.request.get("event_type_str")),
            event_district_enum=EventHelper.parseDistrictName(
                self.request.get("event_district_str")),
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            location=self.request.get("location"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=self.request.get("website"),
            year=int(self.request.get("year")),
            official={
                "true": True,
                "false": False
            }.get(self.request.get("official").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            alliance_selections_json=self.request.get(
                "alliance_selections_json"),
            rankings_json=self.request.get("rankings_json"),
        )
        event = EventManipulator.createOrUpdate(event)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
    def post(self):
        self._require_admin()
        flushed = list()

        if self.request.get("all_keys") == "all_keys":
            memcache.flush_all()
            flushed.append("all memcache values")

        if self.request.get("webcast_keys") == "webcast_keys":
            flushed.append(MemcacheWebcastFlusher.flush())

        if self.request.get('memcache_key') is not "":
            memcache.delete(self.request.get("memcache_key"))
            flushed.append(self.request.get("memcache_key"))

        if self.request.get('return_url') is not "":
            self.redirect("{}?flushed={}".format(self.request.get('return_url'), flushed))
            return

        self.template_values.update({
            "flushed": flushed,
            "memcache_stats": memcache.get_stats(),
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/admin/memcache_index.html')
        self.response.out.write(template.render(path, self.template_values))
    def post(self):
        self._require_admin()
        flushed = list()

        if self.request.get("all_keys") == "all_keys":
            memcache.flush_all()
            flushed.append("all memcache values")

        if self.request.get("webcast_keys") == "webcast_keys":
            flushed.append(MemcacheWebcastFlusher.flush())

        if self.request.get('memcache_key') is not "":
            memcache.delete(self.request.get("memcache_key"))
            flushed.append(self.request.get("memcache_key"))

        if self.request.get('return_url') is not "":
            self.redirect("{}?flushed={}".format(
                self.request.get('return_url'), flushed))
            return

        self.template_values.update({
            "flushed": flushed,
            "memcache_stats": memcache.get_stats(),
        })

        path = os.path.join(os.path.dirname(__file__),
                            '../../templates/admin/memcache_index.html')
        self.response.out.write(template.render(path, self.template_values))
    def add_webcast(cls, event, webcast):
        """Takes a webcast dictionary and adds it to an event"""

        if event.webcast:
            webcasts = event.webcast
            if webcast in webcasts:
                return event
            else:
                webcasts.append(webcast)
                event.webcast_json = json.dumps(webcasts)
        else:
            event.webcast_json = json.dumps([webcast])
        event.dirty = True
        EventManipulator.createOrUpdate(event)
        MemcacheWebcastFlusher.flushEvent(event.key_name)

        return event
Exemplo n.º 13
0
    def add_webcast(cls, event, webcast):
        """Takes a webcast dictionary and adds it to an event"""

        if event.webcast:
            webcasts = event.webcast
            if webcast in webcasts:
                return event
            else:
                webcasts.append(webcast)
                event.webcast_json = json.dumps(webcasts)
        else:
            event.webcast_json = json.dumps([webcast])
        event.dirty = True
        EventManipulator.createOrUpdate(event)
        MemcacheWebcastFlusher.flushEvent(event.key_name)

        return event
    def post(self, event_key_id):

        webcast = dict()
        webcast["type"] = self.request.get("webcast_type")
        webcast["channel"] = self.request.get("webcast_channel")
        if self.request.get("webcast_file"):
            webcast["file"] = self.request.get("webcast_file")

        event = Event.get_by_id(event_key_id)
        if event.webcast:
            webcasts = event.webcast
            webcasts.append(webcast)
            event.webcast_json = json.dumps(webcasts)
        else:
            event.webcast_json = json.dumps([webcast])
        event.dirty = True
        EventManipulator.createOrUpdate(event)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
    def post(self):
        self._require_admin()
        flushed = list()

        if self.request.get("all_keys") == "all_keys":
            memcache.flush_all()
            flushed.append("all memcache values")

        if self.request.get("webcast_keys") == "webcast_keys":
            flushed.append(MemcacheWebcastFlusher.flush())

        if self.request.get('memcache_key') is not "":
            memcache.delete(self.request.get("memcache_key"))
            flushed.append(self.request.get("memcache_key"))

        if self.request.get('event_key') is not "":
            # Clear event page and event teams pages
            event_key = self.request.get('event_key')
            memcache_keys_to_delete = [
                EventDetail().cache_key.format(event_key)
            ]

            event = Event.get_by_id(event_key)
            for team in event.teams:
                memcache_keys_to_delete.append(TeamDetail().cache_key.format(
                    team.key.id(), event.year))
                memcache_keys_to_delete.append(
                    TeamCanonical().cache_key.format(team.key.id()))

            memcache.delete_multi(memcache_keys_to_delete)
            flushed += memcache_keys_to_delete

        if self.request.get('return_url') is not "":
            self.redirect("{}?flushed={}".format(
                self.request.get('return_url'), flushed))
            return

        self.template_values.update({
            "flushed": flushed,
            "memcache_stats": memcache.get_stats(),
        })

        path = os.path.join(os.path.dirname(__file__),
                            '../../templates/admin/memcache_index.html')
        self.response.out.write(template.render(path, self.template_values))
 def post(self):
     flushed = list()
     
     if self.request.get("all_keys") == "all_keys":
         memcache.flush_all()
         flushed.append("all memcache values")
         
     if self.request.get("webcast_keys") == "webcast_keys":
         flushed.append(MemcacheWebcastFlusher.flush())
     
     if self.request.get('memcache_key') is not "":
         memcache.delete(self.request.get("memcache_key"))
         flushed.append(self.request.get("memcache_key"))
     
     template_values = { 
         "flushed" : flushed,
         "memcache_stats": memcache.get_stats(),
     }
     
     path = os.path.join(os.path.dirname(__file__), '../../templates/admin/memcache_index.html')
     self.response.out.write(template.render(path, template_values))
Exemplo n.º 17
0
class ApiTrustedUpdateEventInfo(ApiTrustedBaseController):
    """
    Allow configuring fields for an event
    """

    REQUIRED_AUTH_TYPES = {AuthType.EVENT_INFO}

    ALLOWED_EVENT_PARAMS = {
        "first_event_code",
        "playoff_type",
        "webcasts",  # this is a list of stream URLs, we'll mutate it ourselves
        "remap_teams",
    }

    def _process_request(self, request, event_key):
        try:
            event_info = json.loads(request.body)
        except Exception:
            self._errors = json.dumps({"Error": "Invalid json. Check input."})
            self.abort(400)

        if not isinstance(event_info, dict) or not event_info:
            self._errors = json.dumps({"Error": "Invalid json. Check input."})
            self.abort(400)

        event = Event.get_by_id(event_key)
        if not event:
            self._errors = json.dumps(
                {"Error": "Event {} not found".format(event_key)})
            self.abort(404)

        do_team_remap = False
        for field, value in event_info.iteritems():
            if field not in self.ALLOWED_EVENT_PARAMS:
                continue

            if field == "webcasts":
                # Do special processing here because webcasts are janky
                if not isinstance(value, list):
                    self._errors = json.dumps(
                        {"Error": "Invalid json. Check input"})
                    self.abort(400)
                    return
                webcast_list = []
                for webcast in value:
                    if not isinstance(webcast, dict):
                        self._errors = json.dumps(
                            {"Error": "Invalid json. Check input"})
                        self.abort(400)
                        return
                    if 'url' in webcast:
                        webcast_list.append(
                            WebcastParser.webcast_dict_from_url(
                                webcast['url']))
                    elif 'type' in webcast and 'channel' in webcast:
                        webcast_list.append(webcast)

                webcast_list = [w for w in webcast_list if w is not None]
                EventWebcastAdder.add_webcast(
                    event,
                    webcast_list,
                    False,  # Don't createOrUpdate yet
                )
            elif field == "remap_teams":
                # Validate remap_teams
                if not isinstance(value, dict):
                    raise ParserInputException(
                        "Invalid reamap_teams. Check input")
                for temp_team, remapped_team in value.items():
                    temp_match = re.match(r'frc\d+', str(temp_team))
                    remapped_match = re.match(r'frc\d+[B-Z]?',
                                              str(remapped_team))
                    if not temp_match or (
                            temp_match and
                        (temp_match.group(0) != str(temp_team))):
                        raise ParserInputException(
                            "Bad team: '{}'. Must follow format 'frcXXX'.".
                            format(temp_team))
                    if not remapped_match or (
                            remapped_match and
                        (remapped_match.group(0) != str(remapped_team))):
                        raise ParserInputException(
                            "Bad team: '{}'. Must follow format 'frcXXX' or 'frcXXX[B-Z]'."
                            .format(remapped_team))
                do_team_remap = True
                setattr(event, field, value)
            else:
                try:
                    if field == "first_event_code":
                        event.official = value is not None
                        field = "first_code"  # Internal property is different
                    setattr(event, field, value)
                except Exception, e:
                    self._errors({
                        "Error": "Unable to set event field",
                        "Message": str(e)
                    })
                    self.abort(400)

        EventManipulator.createOrUpdate(event)
        if "webcast" in event_info:
            MemcacheWebcastFlusher.flushEvent(event.key_name)

        if do_team_remap:
            taskqueue.add(
                url='/tasks/do/remap_teams/{}'.format(event.key_name),
                method='GET',
                queue_name='admin',
            )
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"),
                                           "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"),
                                         "%Y-%m-%d")

        first_code = self.request.get("first_code", None)
        district_key = self.request.get("event_district_key", None)
        parent_key = self.request.get("parent_event", None)

        division_key_names = json.loads(
            self.request.get('divisions'),
            '[]') if self.request.get('divisions') else []
        division_keys = [ndb.Key(Event, key) for key in division_key_names
                         ] if division_key_names else []

        website = WebsiteHelper.format_url(self.request.get("website"))

        event = Event(
            id=str(self.request.get("year")) +
            str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            first_code=first_code
            if first_code and first_code != 'None' else None,
            event_type_enum=int(self.request.get("event_type"))
            if self.request.get('event_type') else EventType.UNLABLED,
            district_key=ndb.Key(District,
                                 self.request.get("event_district_key"))
            if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=website,
            first_eid=self.request.get("first_eid"),
            year=int(self.request.get("year")),
            official={
                "true": True,
                "false": False
            }.get(self.request.get("official").lower()),
            enable_predictions={
                "true": True,
                "false": False
            }.get(self.request.get("enable_predictions").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            playoff_type=int(self.request.get("playoff_type")) if
            self.request.get('playoff_type') else PlayoffType.BRACKET_8_TEAM,
            parent_event=ndb.Key(Event, parent_key)
            if parent_key and parent_key.lower() != 'none' else None,
            divisions=division_keys,
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get(
                "rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(
                    self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json")))
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"), "%Y-%m-%d")

        first_code = self.request.get("first_code", None)
        district_key = self.request.get("event_district_key", None)
        parent_key = self.request.get("parent_event", None)

        division_key_names = json.loads(self.request.get('divisions'), '[]') if self.request.get('divisions') else []
        division_keys = [ndb.Key(Event, key) for key in division_key_names] if division_key_names else []

        website = WebsiteHelper.format_url(self.request.get("website"))

        event = Event(
            id=str(self.request.get("year")) + str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            first_code=first_code if first_code and first_code != 'None' else None,
            event_type_enum=int(self.request.get("event_type")) if self.request.get('event_type') else EventType.UNLABLED,
            district_key=ndb.Key(District, self.request.get("event_district_key")) if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=website,
            year=int(self.request.get("year")),
            official={"true": True, "false": False}.get(self.request.get("official").lower()),
            enable_predictions={"true": True, "false": False}.get(self.request.get("enable_predictions").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            playoff_type=int(self.request.get("playoff_type")) if self.request.get('playoff_type') else PlayoffType.BRACKET_8_TEAM,
            parent_event=ndb.Key(Event, parent_key) if parent_key and parent_key.lower() != 'none' else None,
            divisions=division_keys,
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get("rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json"))
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

        self.redirect("/admin/event/" + event.key_name)