def build_heatlist_dancer(self, name): dancers = Heatlist_Dancer.objects.filter(name=name) if dancers.count() > 0: d = dancers.first() else: d = Heatlist_Dancer() d.name = name d.code = "LATE" d.save() return d
def load_dancers(request, comp_id): if not request.user.is_superuser: return render(request, 'rankings/permission_denied.html') comp_objects = Comp.objects.filter(pk=comp_id) if len(comp_objects) == 1: comp = comp_objects[0] #if Heatlist_Dancer.objects.count() > 0: # Heatlist_Dancer.objects.all().delete() if Unmatched_Heat_Entry.objects.count() > 0: Unmatched_Heat_Entry.objects.all().delete() if comp.heatsheet_file: heatlist = FileBasedHeatlist() heatlist.open(comp.heatsheet_file) else: if comp.url_data_format == Comp.COMP_MNGR: heatlist = CompMngrHeatlist() elif comp.url_data_format == Comp.NDCA_PREM: heatlist = NdcaPremHeatlist() elif comp.url_data_format == Comp.NDCA_FEED: heatlist = NdcaPremFeedHeatlist() elif comp.url_data_format == Comp.O2CM: heatlist = O2cmHeatlist() else: # CompOrganizer for now heatlist = CompOrgHeatlist() heatlist.open(comp) # add special "dancer" for partnerless events d = Heatlist_Dancer() d.name = "{No, Partner}" d.code = "0" d.comp = comp heatlist.dancers.append(d) for d in heatlist.dancers: in_database = Heatlist_Dancer.objects.filter(name=d.name, comp=comp) if in_database.count() == 0: d.save() comp.process_state = Comp.DANCERS_LOADED comp.save() return redirect("comps:resolve_dancers", comp.id)