def _delete(self, **kwargs): event_id = kwargs.pop('id') event = EventAPI(self.request).editSelf(id=event_id) event_activities = EventActivityAPI( self.request).filterSelf(event_activity_event_parent=event.id) event_summaries = SummaryAPI( self.request).filterSelf(summary_event_parent=event.id) event_tags = EventTagAPI( self.request).filterSelf(event_tag_event_id=event.id) event_teams = EventAPI( self.request).getEventCascadeTeams(event_id=event.id) event_team_links = [ EventTeamAPI(self.request).filterSelf( event_team_event_activity_id=activity.id) for activity in event_activities ] for team in event_teams: team.delete() for tag in event_tags: tag.delete() for summary in event_summaries: summary.delete() for activity in event_activities: activity.delete() for team_links in event_team_links: for team_link in team_links: team_link.delete() event.delete()
def getFieldData(self, **kwargs): action = kwargs.pop('action') element_id = kwargs.pop('element_id') field_data = dict(event_type=EventType.FLEET_RACE) if self.populate_data_dispatcher.get(action): raw_data = EventAPI(self.request).editSelf(id=element_id).__dict__ field_data = MiscFunctions.filterDict(raw_data.items(), self.validation_set) field_data['event_team'] = raw_data['event_school_ids'] field_data = MiscFunctions.serializeJSONListData( ['event_school_ids', 'event_rotation_detail'], field_data) return field_data return field_data
def generateList(self): event_type = dict( (y, x) for x, y in Choices().getEventTypeChoices())[self.param["type"]] def genDict(status): events = event_api.filterSelf(event_status=status, event_type=event_type) event_dict = map( lambda event: dict( element_text=event.event_name, element_link=reverse( 'panel.module.management_event.view_dispatch_param', args=['activity', event.id]), elements=[ dict( text='Teams', link=reverse( 'panel.module.management_event.view_dispatch_param', args=['team', event.id])), dict(text='Races (WIP)', link='#'), dict(text='Manage', link=event_api.getEventModifyLink( self.param["type"], id=event.id)) ]), [event for event in events]) return BlockObject(status, 'Event', ['', '', ''], event_dict) event_api = EventAPI(self.request) return BlockSet().makeBlockSet(genDict('future'), genDict('running'), genDict('done'))
def generateList(self): def genDict(status): events = event_api.filterSelf(event_status=status) change_status_dict = dict(future='running', running='done', done='not applicable') event_dict = list( map( lambda event: dict( element_text=event.event_name, element_link=reverse( 'panel.module.management_ranking.view_dispatch_param', args=['activity', event.id]), elements=[ dict( text=change_status_dict[event.event_status], link=reverse( 'panel.module.management_ranking.process_dispatch_param', args=[ 'activity status', str(event.id) + '|' + change_status_dict[event.event_status] ]) if event.event_status != 'done' else '#') ]), [event for event in events])) return BlockObject(status, 'Event', ['Change Status'], event_dict) event_api = EventAPI(self.request) return BlockSet().makeBlockSet(genDict('future'), genDict('running'), genDict('done'))
def getRowContent(self, model_object): field_data = MiscFunctions.filterDict( EventAPI( self.request).getSelf(id=model_object.id).__dict__.items(), self.validation_set) date = '{} to {}'.format(str(field_data['event_start_date']), str(field_data['event_end_date'])) del field_data['event_start_date'] del field_data['event_end_date'] field_data['date'] = date field_data = MiscUtils(self.request).updateChoiceAsValue( field_data, FleetRaceForm(self.request, self.app_name, self.base_class, self.mutable, self.guard).getChoiceData()) field_data = MiscFunctions.serializeJSONListData( ['event_school_ids', 'event_rotation_detail'], field_data) field_data = MiscFunctions.grabValueAsList(field_data) return field_data
url(r"^$", IndexView.as_view()), url(r"^companies/$", CompanyList.as_view(), name="reserved_companies"), url(r"^events/$", EventList.as_view(), name="event_list"), url(r"^events/new/$", EventCreate.as_view(), name="event_create"), url(r"^venues/$", VenueList.as_view(), name="reserved_venues"), url(r"^venues/new/$", VenueCreate.as_view(), name="venues_create"), url(r"^venues/calendar/$", VenueCalendarView.as_view(), name="venues_calendar"), url( r"^venues/calendar/(?P<date_str>[0-9]{4}-[0-9]{2}-[0-9]{2})[/](?P<name_range>[\w]{0,}[^/])/$", VenueCalendarView.as_view(), name="reserved_venues__date_calendar", ), url(r"^bookings/$", BookingList.as_view(), name="reserved_bookings"), url(r"^bookings/new/$", BookingCreate.as_view(), name="bookings_create"), url(r"^bookings/detail/(?P<slug>[-_\w]+)/$", BookingDetail.as_view(), name="bookings_detail"), (r"^accounts/", include("userena.urls")), url(r"^admin/", include(admin.site.urls)), ) urlpatterns += patterns( "", url(r"^api/bookings/$", BookingsAPI.as_view(), name="bookings_api"), url(r"^api/bookings/(?P<booking_id>[0-9]+)/?$", BookingsAPI.as_view(), name="bookings_id_api"), url(r"^api/bookings/(?P<booking_id>[0-9]+)/customers/?$", CustomersAPI.as_view(), name="bookings_id_customers_api"), url(r"^api/customers/?$", CustomersAPI.as_view(), name="customer_api"), url(r"^api/customers/(?P<customer_id>[0-9]+)/?$", CustomersAPI.as_view(), name="customer_id_api"), url(r"^api/events/$", EventAPI.as_view(), name="event_api"), url(r"^api/locations/$", LocationAPI.as_view(), name="locations_api"), url(r"^api/locations/(?P<location_id>[0-9]+)/?$", LocationAPI.as_view(), name="locations_id_api"), )
urlpatterns += patterns('', url(r'^api/bookings/$' , BookingsAPI.as_view() , name='bookings_api'), url(r'^api/bookings/(?P<booking_id>[0-9]+)/?$' , BookingsAPI.as_view() , name='bookings_id_api'), url(r'^api/bookings/(?P<booking_id>[0-9]+)/customers/?$' , CustomersAPI.as_view() , name='bookings_id_customers_api'), url(r'^api/customers/?$' , CustomersAPI.as_view() , name='customer_api'), url(r'^api/customers/(?P<customer_id>[0-9]+)/?$' , CustomersAPI.as_view() , name='customer_id_api'), url(r'^api/events/$' , EventAPI.as_view() , name='event_api'), url(r'^api/locations/$' , LocationAPI.as_view() , name='locations_api'), url(r'^api/locations/(?P<location_id>[0-9]+)/?$' , LocationAPI.as_view() , name='locations_id_api'), ) urlpatterns += patterns('', url(r'^menu/$' , MenuList.as_view() , name='menu'), url(r'^menu/json/$' , MenuJson.as_view() , name='menu_json'), url(r'^menu/data.js$' , MenuData.as_view() , name='menu_data'),
def generateList(self): def genActivityDict(tag): event_activities = event_activity_api.filterSelf( event_activity_event_parent=event_id, event_activity_event_tag=tag.id) event_activities = sorted(list(event_activities), key=(lambda x: x.event_activity_order)) event_activity_dict = map( lambda event_activity: dict( element_text=event_activity.event_activity_name, element_link=reverse( 'panel.module.management_event.view_dispatch_param', args=['activity detail', event_activity.id]), elements=[ dict(text='Modify', link=event_activity_api. getEventActivityModifyLink(id=event_activity.id)) ]), [event_activity for event_activity in event_activities]) return BlockObject(tag.event_tag_name, 'Event Activity', ['Modify'], event_activity_dict) def genTagDict(event_id): event_tags = event_tag_api.filterSelf(event_tag_event_id=event_id) event_tags = sorted(list(event_tags), key=(lambda x: x.id)) event_tag_dict = map( lambda event_tag: dict(element_text=event_tag.event_tag_name, element_link=event_tag_api. getEventTagModifyLink(id=event_tag.id), elements=[]), [event_tag for event_tag in event_tags]) return BlockObject('Event Tags', 'Event Tag', [], event_tag_dict) def genSummaryDict(event_id): event_summaries = summary_api.filterSelf( summary_event_parent=event_id) event_summaries = sorted(list(event_summaries), key=(lambda x: x.id)) event_summary_dict = map( lambda event_summary: dict( element_text='Summary - ' + school_api.getSelf( id=event_summary.summary_event_school).school_name, element_link=summary_api.getEventSummaryModifiyLink( id=event_summary.id), elements=[]), [event_summary for event_summary in event_summaries]) return BlockObject('Event Summaries', 'Event Summary', [], event_summary_dict) def genTeamDict(event_id): event_teams = event_api.getEventCascadeTeams(event_id) event_teams = sorted(list(event_teams), key=(lambda x: x.id)) event_team_dict = map( lambda event_team: dict(element_text=school_api.getSelf(id=event_team.team_school) .school_name + ' - ' + event_team.team_name, element_link=team_api.getTeamModifyLink(id=event_team.id), elements=[]), [event_team for event_team in event_teams]) return BlockObject('Event Teams', 'Event Team', [], event_team_dict) event_id = int(self.param["id"]) event_api = EventAPI(self.request) event_activity_api = EventActivityAPI(self.request) event_tag_api = EventTagAPI(self.request) school_api = SchoolAPI(self.request) summary_api = SummaryAPI(self.request) team_api = TeamAPI(self.request) blockset = BlockSet().makeBlockSet( *[ genActivityDict(event_tag) for event_tag in event_tag_api.filterSelf( event_tag_event_id=event_id) ], # event_activity_result genTagDict(event_id), # event_tag_result genSummaryDict(event_id), # event_summary_result genTeamDict(event_id) # event_team_result ) return blockset
def process(self): if AuthFunctions.signed_in(self.request, 'admin'): event_api = EventAPI(self.request) event_api.updateEventStatus(int(self.param["id"]), self.param["status"]) return redirect(reverse('panel.module.management_ranking.view_dispatch', args=['event']))
def genContent(self): def getScoreOptions(school_id): options = { **{ str(i + 1): dict(selected='', text=str(i + 1)) for i in range(event_team_number) }, **{ choice: dict(selected='', text=choice) for scoremap_id, choice in CustomElements.Choices().getScoreMapChoices( ) } } options = setDefaultOption(school_id, options) return options def setDefaultOption(school_id, options): try: school_result = event_activity_result[str(school_id)] options[school_result]['selected'] = 'selected' except KeyError: print("Result Has Not Been Set Yet.") return options def getEventSpecificRotation(event_rotation, order, tag): return { key: rotation[order - 1] for key, rotation in event_rotation[str(tag)].items() } def getEventActivitySchool(event_specific_rotation): event_activity_teams = [ i[0] for i in sorted(event_specific_rotation.items(), key=(lambda x: int(x[1]))) ] result = { school_team_tuple[0]: school_team_tuple[1] for school_team_tuple in [(lambda x: (school_api.getSelf(id=x.team_school), x) )(team_api.getSelf(id=event_activity_team_id)) for event_activity_team_id in event_activity_teams] } return result def compileContent(event_boat_identifiers, event_activity_schools, event_team_number): return { str(i + 1): dict(boat_identifier=event_boat_identifiers[i], school_name=list( event_activity_schools.keys())[i].school_name, event_activity_team=list( event_activity_schools.values())[i].id, options=getScoreOptions( list(event_activity_schools.values())[i].id)) for i in range(event_team_number) } event_activity_id = int(self.param["id"]) event_api = EventAPI(self.request) event_activity_api = EventActivityAPI(self.request) school_api = SchoolAPI(self.request) team_api = TeamAPI(self.request) event_activity = event_activity_api.getSelf(id=event_activity_id) event = event_api.getSelf( id=int(event_activity.event_activity_event_parent)) event_boat_identifiers = event.event_boat_rotation_name.split(',') event_rotation = event.event_rotation_detail event_activity_tag = event_activity.event_activity_event_tag event_team_number = event.event_team_number event_activity_order = event_activity.event_activity_order event_activity_result = event_activity.event_activity_result event_specific_rotation = getEventSpecificRotation( event_rotation, event_activity_order, event_activity_tag) event_activity_schools = getEventActivitySchool( event_specific_rotation) content = compileContent(event_boat_identifiers, event_activity_schools, event_team_number) return content