def handle_round(self, round, **options): self.stdout.write("Deleting all debates in round '{}'...".format(round.name)) Debate.objects.filter(round=round).delete() round.draw_status = Round.STATUS_NONE round.save() self.stdout.write("Checking in all teams, adjudicators and venues for round '{}'...".format(round.name)) activate_all(round) self.stdout.write("Generating a draw for round '{}'...".format(round.name)) DrawManager(round).create() allocate_venues(round) round.draw_status = Round.STATUS_CONFIRMED round.save() self.stdout.write("Auto-allocating adjudicators for round '{}'...".format(round.name)) if round.ballots_per_debate == 'per-adj': allocator_class = VotingHungarianAllocator else: allocator_class = ConsensusHungarianAllocator allocate_adjudicators(round, allocator_class) self.stdout.write("Generating results for round '{}'...".format(round.name)) add_results_to_round(round, **self.result_kwargs(options)) round.tournament.current_round = round round.tournament.save()
def handle_round(self, round, **options): self.stdout.write("Deleting all debates in round '{}'...".format( round.name)) Debate.objects.filter(round=round).delete() round.draw_status = Round.STATUS_NONE round.save() self.stdout.write( "Checking in all teams, adjudicators and venues for round '{}'...". format(round.name)) activate_all(round) self.stdout.write("Generating a draw for round '{}'...".format( round.name)) DrawManager(round).create() allocate_venues(round) round.draw_status = Round.STATUS_CONFIRMED round.save() self.stdout.write( "Auto-allocating adjudicators for round '{}'...".format( round.name)) if round.ballots_per_debate == 'per-adj': allocator_class = VotingHungarianAllocator else: allocator_class = ConsensusHungarianAllocator allocate_adjudicators(round, allocator_class) self.stdout.write("Generating results for round '{}'...".format( round.name)) add_results_to_round(round, **self.result_kwargs(options)) round.tournament.current_round = round round.tournament.save()
def post(self, request, *args, **kwargs): round = self.get_round() if round.draw_status != round.STATUS_NONE: messages.error(request, "Could not create draw for {}, there was already a draw!".format(round.name)) return super().post(request, *args, **kwargs) manager = DrawManager(round) try: manager.create() except DrawError as e: messages.error(request, "There was a problem creating the draw: " + str(e) + " If this " " issue persists and you're not sure how to resolve it, please contact the developers.") logger.critical(str(e), exc_info=True) return HttpResponseRedirect(reverse_round('availability-index', round)) relevant_adj_venue_constraints = AdjudicatorVenueConstraint.objects.filter( Q(adjudicator__tournament=self.get_tournament()) | Q(adjudicator__tournament__isnull=True) ) if not relevant_adj_venue_constraints.exists(): allocate_venues(round) else: messages.warning(request, "Venues were not auto-allocated because there are one or more adjudicator venue constraints. " "You should run venue allocations after allocating adjudicators.") self.log_action() return super().post(request, *args, **kwargs)
def post(self, request, *args, **kwargs): round = self.get_round() if round.draw_status != round.STATUS_NONE: messages.error(request, "Could not create draw for {}, there was already a draw!".format(round.name)) return super().post(request, *args, **kwargs) manager = DrawManager(round) manager.create() allocate_venues(round) self.log_action() return super().post(request, *args, **kwargs)
def post(self, request, *args, **kwargs): if self.round.draw_status != Round.STATUS_NONE: messages.error(request, _("Could not create draw for %(round)s, there was already a draw!") % {'round': self.round.name}) return super().post(request, *args, **kwargs) try: manager = DrawManager(self.round) manager.create() except DrawUserError as e: messages.error(request, mark_safe(_( "<p>The draw could not be created, for the following reason: " "<em>%(message)s</em></p>\n" "<p>Please fix this issue before attempting to create the draw.</p>", ) % {'message': str(e)})) logger.warning("User error creating draw: " + str(e), exc_info=True) return HttpResponseRedirect(reverse_round('availability-index', self.round)) except DrawFatalError as e: messages.error(request, mark_safe(_( "<p>The draw could not be created, because the following error occurred: " "<em>%(message)s</em></p>\n" "<p>If this issue persists and you're not sure how to resolve it, please " "contact the developers.</p>", ) % {'message': str(e)})) logger.exception("Fatal error creating draw: " + str(e)) return HttpResponseRedirect(reverse_round('availability-index', self.round)) except StandingsError as e: message = _( "<p>The team standings could not be generated, because the following error occurred: " "<em>%(message)s</em></p>\n" "<p>Because generating the draw uses the current team standings, this " "prevents the draw from being generated.</p>", ) % {'message': str(e)} standings_options_url = reverse_tournament('options-tournament-section', self.tournament, kwargs={'section': 'standings'}) instructions = BaseStandingsView.admin_standings_error_instructions % {'standings_options_url': standings_options_url} messages.error(request, mark_safe(message + instructions)) logger.exception("Error generating standings for draw: " + str(e)) return HttpResponseRedirect(reverse_round('availability-index', self.round)) relevant_adj_venue_constraints = VenueConstraint.objects.filter( adjudicator__in=self.tournament.relevant_adjudicators) if not relevant_adj_venue_constraints.exists(): allocate_venues(self.round) else: messages.warning(request, _("Rooms were not auto-allocated because there are one or more adjudicator room constraints. " "You should run room allocations after allocating adjudicators.")) self.log_action() return super().post(request, *args, **kwargs)
def post(self, request, *args, **kwargs): if self.round.draw_status != Round.STATUS_NONE: messages.error(request, _("Could not create draw for %(round)s, there was already a draw!") % {'round': self.round.name}) return super().post(request, *args, **kwargs) try: manager = DrawManager(self.round) manager.create() except DrawUserError as e: messages.error(request, mark_safe(_( "<p>The draw could not be created, for the following reason: " "<em>%(message)s</em></p>\n" "<p>Please fix this issue before attempting to create the draw.</p>" ) % {'message': str(e)})) logger.warning("User error creating draw: " + str(e), exc_info=True) return HttpResponseRedirect(reverse_round('availability-index', self.round)) except DrawFatalError as e: messages.error(request, mark_safe(_( "The draw could not be created, because the following error occurred: " "<em>%(message)s</em></p>\n" "<p>If this issue persists and you're not sure how to resolve it, please " "contact the developers.</p>" ) % {'message': str(e)})) logger.exception("Fatal error creating draw: " + str(e)) return HttpResponseRedirect(reverse_round('availability-index', self.round)) except StandingsError as e: message = _( "<p>The team standings could not be generated, because the following error occurred: " "<em>%(message)s</em></p>\n" "<p>Because generating the draw uses the current team standings, this " "prevents the draw from being generated.</p>" ) % {'message': str(e)} standings_options_url = reverse_tournament('options-tournament-section', self.tournament, kwargs={'section': 'standings'}) instructions = BaseStandingsView.admin_standings_error_instructions % {'standings_options_url': standings_options_url} messages.error(request, mark_safe(message + instructions)) logger.exception("Error generating standings for draw: " + str(e)) return HttpResponseRedirect(reverse_round('availability-index', self.round)) relevant_adj_venue_constraints = VenueConstraint.objects.filter( adjudicator__in=self.tournament.relevant_adjudicators) if not relevant_adj_venue_constraints.exists(): allocate_venues(self.round) else: messages.warning(request, _("Venues were not auto-allocated because there are one or more adjudicator venue constraints. " "You should run venue allocations after allocating adjudicators.")) self.log_action() return super().post(request, *args, **kwargs)
def post(self, request, *args, **kwargs): round = self.get_round() if round.draw_status != round.STATUS_NONE: messages.error( request, "Could not create draw for {}, there was already a draw!". format(round.name)) return super().post(request, *args, **kwargs) manager = DrawManager(round) try: manager.create() except DrawError as e: messages.error( request, "There was a problem creating the draw: " + str(e) + " If this " " issue persists and you're not sure how to resolve it, please contact the developers." ) logger.error(str(e), exc_info=True) return HttpResponseRedirect( reverse_round('availability-index', round)) relevant_adj_venue_constraints = VenueConstraint.objects.filter( adjudicator__in=self.get_tournament().relevant_adjudicators) if not relevant_adj_venue_constraints.exists(): allocate_venues(round) else: messages.warning( request, "Venues were not auto-allocated because there are one or more adjudicator venue constraints. " "You should run venue allocations after allocating adjudicators." ) self.log_action() return super().post(request, *args, **kwargs)