def add(): event_api = self.useAPI(self.assoc_class_event) event_activity = self.base_class() event_activity.event_activity_event_parent = int( [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[0] + "_result")][0]) event_activity.event_activity_event_tag = int( [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[1] + "_result")][0]) event_activity.event_activity_name = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_name') event_activity.event_activity_order = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_order') event_activity.event_activity_result = MiscFunctions.jsonLoadCatch( RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_result')) event_activity.event_activity_type = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_type') event_activity.event_activity_note = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_note') event_activity.event_activity_status = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_status') event_activity.save() LogFunctions.generateLog( self.request, 'admin', LogFunctions.makeLogQuery( self.base_class, action.title(), id=event_activity.id)) teams = event_api.getEventCascadeTeams(event_activity.event_activity_event_parent) matching_teams = list(filter(lambda x: x.team_tag_id == event_activity.event_activity_event_tag, teams)) for team in matching_teams: event_team = self.assoc_class_team_link() event_team.event_team_event_activity_id = event_activity.id event_team.event_team_id = team.id event_team.save() LogFunctions.generateLog( self.request, 'admin', LogFunctions.makeLogQuery( self.assoc_class_team_link, action.title(), id=event_team.id)) event = event_api.getSelf(id=event_activity.event_activity_event_parent) event_type = int(event.event_type) event_team_num = int(event.event_team_number) event_rotation = event.event_rotation_detail event_tag = event_activity.event_activity_event_tag new_rotation = {} if event_type == 1: new_rotation = self.__fleetRotationUpdater(event_tag, event_team_num, 'add', event_rotation) elif event_type == 2: new_rotation = self.__teamRotationUpdater() event.event_rotation_detail = new_rotation event.save() LogFunctions.generateLog( self.request, 'admin', LogFunctions.makeLogQuery( self.assoc_class_event, action.title(), id=event.id))
def edit(key): event_activity = self.useAPI(self.base_class).editSelf(id=key) event_activity.event_activity_event_parent = int( [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[0] + "_result")][0]) event_activity.event_activity_event_tag = int( [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[1] + "_result")][0]) event_activity.event_activity_name = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_name') event_activity.event_activity_order = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_order') event_activity.event_activity_result = MiscFunctions.jsonLoadCatch( RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_result')) event_activity.event_activity_type = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_type') event_activity.event_activity_note = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_note') event_activity.event_activity_status = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_status') event_activity.save() LogFunctions.generateLog( self.request, 'admin', LogFunctions.makeLogQuery( self.base_class, action.title(), id=event_activity.id))
def abstractFormProcess(self, action, **kwargs): try: if not action == 'edit': raise Exception( 'Trying to ' + action + ' event in Logic-less Event Data Management Panel') post_dict = dict(self.request.POST) event_type = RequestFunctions.getSinglePostObj( post_dict, 'event_type') event_class = RequestFunctions.getSinglePostObj( post_dict, 'event_class') event_name = RequestFunctions.getSinglePostObj( post_dict, 'event_name') event_status = RequestFunctions.getSinglePostObj( post_dict, 'event_status') event_description = RequestFunctions.getSinglePostObj( post_dict, 'event_description') event_location = RequestFunctions.getSinglePostObj( post_dict, 'event_location') event_season = RequestFunctions.getSinglePostObj( post_dict, 'event_season') event_region = RequestFunctions.getSinglePostObj( post_dict, 'event_region') event_host = RequestFunctions.getSinglePostObj( post_dict, 'event_host') event_school = RequestFunctions.getMultiplePostObj( post_dict, 'event_team') event_race_number = RequestFunctions.getSinglePostObj( post_dict, 'event_race_number') event_boat_rotation_name = RequestFunctions.getSinglePostObj( post_dict, 'event_boat_rotation_name') event_rotation_detail = MiscFunctions.jsonLoadCatch( RequestFunctions.getSingleRequestObj(post_dict, 'event_rotation_detail')) event_start_date = RequestFunctions.getSingleRequestObj( post_dict, 'event_start_date') event_end_date = RequestFunctions.getSingleRequestObj( post_dict, 'event_end_date') dispatcher = super().populateDispatcher() if dispatcher.get(action): event_creation_id = kwargs.pop('id', None) event_creation = self.useAPI( self.base_class).editSelf(id=event_creation_id) else: event_creation = self.base_class() # event generation event_creation.event_type = int(event_type) event_creation.event_class = int(event_class) event_creation.event_name = event_name event_creation.event_status = event_status event_creation.event_description = event_description event_creation.event_location = event_location event_creation.event_season = int(event_season) event_creation.event_region = int(event_region) event_creation.event_host = int(event_host) event_creation.event_race_number = int(event_race_number) event_creation.event_boat_rotation_name = event_boat_rotation_name event_creation.event_start_date = event_start_date event_creation.event_end_date = event_end_date event_creation.event_team_number = 0 if event_school is None else len( event_school) event_creation.event_school_ids = [] if event_school is None else event_school event_creation.event_rotation_detail = event_rotation_detail event_creation.save() if not action == 'edit': event_creation.save() LogFunctions.generateLog( self.request, 'admin', LogFunctions.makeLogQuery(self.base_class, action.title(), id=event_creation.id)) except Exception as e: print({"Error": "Cannot Process " + action.title() + " Request."}) print(e)