def get(self, request, pk): data = [[user.comment, user.code] for user in self.contest.contestinvitation_set.all()] filename = write_csv(data) return respond_generate_file( request, filename, file_name_serve_as="InvitationCode - %s.csv" % self.contest.title)
def get(self, request, pk): data = [[user.comment, user.user.username, user.hidden_comment] for user in self.contest.contestparticipant_set.select_related( "user").all()] filename = write_csv(data) return respond_generate_file( request, filename, file_name_serve_as="ContestParticipant - %s.csv" % self.contest.title)
def get(self, request, cid): if not self.privileged: raise PermissionDenied rank_list = get_contest_rank(self.contest) contest_participants = { user.user_id: user for user in ContestParticipant.objects.filter( contest=self.contest).select_related('user', 'contest').all() } header = ["Rank", "Username", "Info", "E-mail", "Name", "Score"] if self.contest.contest_type == 0 and self.contest.penalty_counts: header.append("Penalty") for problem in self.contest.contest_problem_list: header.append(problem.identifier) data = [header] for rank in rank_list: d = [] d.append( str(rank["actual_rank"]) if rank.get("actual_rank") else "") participant = contest_participants[rank['user']] d.append(participant.user.username) d.append(participant.comment) d.append(participant.user.email) d.append(participant.user.name) d.append(str(rank["score"])) if self.contest.contest_type == 0 and self.contest.penalty_counts: d.append(str(rank["penalty"] // 60)) for problem in self.contest.contest_problem_list: detail = rank["detail"].get(problem.problem_id) text = '' if detail and not detail.get("waiting", False) and detail.get("attempt"): if self.contest.scoring_method != "acm": text = str(detail["score"]) elif detail["solved"]: text = "+" + str(detail["attempt"] - 1) if self.contest.contest_type == 1: text += '(%s)' % (detail["pass_time"]) elif self.contest.penalty_counts: text += "(%d)" % (detail["time"] // 60) else: text = "-" + str(detail["attempt"]) d.append(text) data.append(d) file_name = write_csv(data) return respond_generate_file( request, file_name, file_name_serve_as="ContestStandings - %s.csv" % self.contest.title)