本文整理汇总了Python中utils.misc.reverse_tournament函数的典型用法代码示例。如果您正苦于以下问题:Python reverse_tournament函数的具体用法?Python reverse_tournament怎么用?Python reverse_tournament使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reverse_tournament函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: serialize
def serialize(self, tournament=None):
if not tournament:
tournament = self.debate.round.tournament
# Shown in the results page on a per-ballot; always measured in tab TZ
created_short = timezone.localtime(self.timestamp).strftime("%H:%M")
# These are used by the status graph
created = timezone.localtime(self.timestamp).isoformat()
confirmed = None
if self.confirm_timestamp and self.confirmed:
confirmed = timezone.localtime(self.confirm_timestamp).isoformat()
return {
'ballot_id': self.id,
'debate_id': self.debate.id,
'submitter': self.submitter.username if self.submitter else self.ip_address,
'admin_link': reverse_tournament('results-ballotset-edit',
tournament, kwargs={'pk': self.id}),
'assistant_link': reverse_tournament('results-assistant-ballotset-edit',
tournament, kwargs={'pk': self.id}),
'short_time': created_short,
'created_timestamp': created,
'confirmed_timestamp': confirmed,
'version': self.version,
'confirmed': self.confirmed,
'discarded': self.discarded,
}
开发者ID:czlee,项目名称:tabbycat,代码行数:27,代码来源:models.py
示例2: get_tables
def get_tables(self):
tournament = self.tournament
teams = tournament.team_set.all().annotate(feedback_count=Count('debateteam__adjudicatorfeedback')).prefetch_related('speaker_set')
team_table = TabbycatTableBuilder(
view=self, title=_('From Teams'), sort_key='team')
team_table.add_team_columns(teams)
team_feedback_data = []
for team in teams:
count = team.feedback_count
team_feedback_data.append({
'text': ngettext("%(count)d feedback", "%(count)d feedbacks", count) % {'count': count},
'link': reverse_tournament('adjfeedback-view-from-team',
tournament,
kwargs={'pk': team.id}),
})
team_table.add_column({'key': 'feedbacks', 'title': _("Feedbacks")}, team_feedback_data)
adjs = tournament.adjudicator_set.all().annotate(feedback_count=Count('debateadjudicator__adjudicatorfeedback'))
adj_table = TabbycatTableBuilder(
view=self, title=_('From Adjudicators'), sort_key='name')
adj_table.add_adjudicator_columns(adjs)
adj_feedback_data = []
for adj in adjs:
count = adj.feedback_count
adj_feedback_data.append({
'text': ngettext("%(count)d feedback", "%(count)d feedbacks", count) % {'count': count},
'link': reverse_tournament('adjfeedback-view-from-adjudicator',
tournament,
kwargs={'pk': adj.id}),
})
adj_table.add_column({'key': 'feedbacks', 'title': _("Feedbacks")}, adj_feedback_data)
return [team_table, adj_table]
开发者ID:czlee,项目名称:tabbycat,代码行数:34,代码来源:views.py
示例3: get_context_data
def get_context_data(self, **kwargs):
tournament = self.get_tournament()
teams_data = []
for team in Team.objects.filter(tournament=tournament):
feedbacks = AdjudicatorFeedback.objects.filter(source_team__team=team).select_related(
'source_team__team').count()
teams_data.append({
'name': team.short_name,
'institution': team.institution.name,
'feedbacks': "%s Feedbacks" % feedbacks,
'rowLink': reverse_tournament('adjfeedback-view-from-team', tournament, kwargs={'pk': team.pk}),
})
adjs_data = []
for adj in Adjudicator.objects.filter(tournament=tournament):
feedbacks = AdjudicatorFeedback.objects.filter(source_adjudicator__adjudicator=adj).select_related(
'source_adjudicator__adjudicator').count(),
adjs_data.append({
'name': adj.name,
'institution': adj.institution.name,
'feedbacks': "%s Feedbacks" % feedbacks,
'rowLink': reverse_tournament('adjfeedback-view-from-adjudicator', tournament, kwargs={'pk': adj.pk}),
})
kwargs['teams'] = teams_data
kwargs['adjs'] = adjs_data
return super().get_context_data(**kwargs)
开发者ID:jzbahrai,项目名称:tabbycat,代码行数:26,代码来源:views.py
示例4: get_success_url
def get_success_url(self):
# Redirect to non-cached page: the public feedback form
if isinstance(self.object, Adjudicator):
return reverse_tournament('adjfeedback-public-add-from-adjudicator-pk',
self.tournament, kwargs={'source_id': self.object.id})
elif isinstance(self.object, Team):
return reverse_tournament('adjfeedback-public-add-from-team-pk',
self.tournament, kwargs={'source_id': self.object.id})
else:
raise ValueError("Public feedback source is not of a valid type")
开发者ID:czlee,项目名称:tabbycat,代码行数:10,代码来源:views.py
示例5: _result_cell_two
def _result_cell_two(self, ts, compress=False, show_score=False, show_ballots=False):
if not hasattr(ts, 'debate_team') or not hasattr(ts.debate_team.opponent, 'team'):
return {'text': self.BLANK_TEXT}
opp = ts.debate_team.opponent.team
opp_vshort = '<i class="emoji">' + opp.emoji + '</i>' if opp.emoji else "…"
cell = {
'text': _(" vs %(opposition)s") % {'opposition': opp_vshort if compress else self._team_short_name(opp)},
'popover': {'content': [], 'title': ''},
'class': "no-wrap",
}
cell = self._result_cell_class_two(ts.win, cell)
if ts.win is True:
cell['popover']['title'] = _("Won against %(team)s") % {'team': self._team_long_name(opp)}
elif ts.win is False:
cell['popover']['title'] = _("Lost to %(team)s") % {'team': self._team_long_name(opp)}
else: # None
cell['popover']['title'] = _("No result for debate against %(team)s") % {'team': self._team_long_name(opp)}
if show_score and ts.score is not None:
score = ts.score
if self.tournament.integer_scores(ts.debate_team.debate.round.stage) and score.is_integer():
score = int(ts.score)
cell['subtext'] = metricformat(score)
cell['popover']['content'].append(
{'text': _("Total speaker score: <strong>%s</strong>") % metricformat(score)})
if show_ballots:
if self.admin:
cell['popover']['content'].append({
'text': _("View/edit debate ballot"),
'link': reverse_tournament('results-ballotset-edit',
self.tournament, kwargs={'pk': ts.ballot_submission_id})
})
elif self.tournament.pref('ballots_released'):
cell['popover']['content'].append({
'text': _("View debate ballot"),
'link': reverse_tournament('results-public-scoresheet-view',
self.tournament, kwargs={'pk': ts.debate_team.debate_id})
})
if self._show_speakers_in_draw:
cell['popover']['content'].append({
'text': ", ".join([s.name for s in opp.speakers])
})
if self._show_record_links:
cell['popover']['content'].append(
self._team_record_link(opp))
return cell
开发者ID:czlee,项目名称:tabbycat,代码行数:53,代码来源:tables.py
示例6: _team_record_link
def _team_record_link(self, team):
if self.admin:
return {
'text': _("View %(team)s's Record") % {'team': self._team_short_name(team)},
'link': reverse_tournament('participants-team-record', self.tournament, kwargs={'pk': team.pk})
}
elif self.tournament.pref('public_record'):
return {
'text': _("View %(team)s's Record") % {'team': self._team_short_name(team)},
'link': reverse_tournament('participants-public-team-record', self.tournament, kwargs={'pk': team.pk})
}
else:
return {'text': '', 'link': False}
开发者ID:czlee,项目名称:tabbycat,代码行数:13,代码来源:tables.py
示例7: get_context_data
def get_context_data(self, **kwargs):
speaker_categories = self.tournament.speakercategory_set.all()
json_categories = [bc.serialize for bc in speaker_categories]
kwargs["speaker_categories"] = json.dumps(json_categories)
kwargs["speaker_categories_length"] = speaker_categories.count()
kwargs["save"] = reverse_tournament('participants-speaker-update-eligibility', self.tournament)
return super().get_context_data(**kwargs)
开发者ID:czlee,项目名称:tabbycat,代码行数:7,代码来源:views.py
示例8: dispatch
def dispatch(self, request, *args, **kwargs):
tournament = self.tournament
if tournament.current_round_id is None:
full_path = self.request.get_full_path()
if hasattr(self.request, 'user') and self.request.user.is_superuser:
logger.warning("Current round wasn't set, redirecting to set-current-round page")
set_current_round_url = reverse_tournament('tournament-set-current-round', self.tournament)
redirect_url = add_query_parameter(set_current_round_url, 'next', full_path)
return HttpResponseRedirect(redirect_url)
else:
logger.warning("Current round wasn't set, redirecting to site index")
messages.warning(request, _("There's a problem with the data for the tournament "
"%(tournament_name)s. Please contact a tab director and ask them to set its "
"current round.") % {'tournament_name': tournament.name})
home_url = reverse('tabbycat-index')
redirect_url = add_query_parameter(home_url, 'redirect', 'false')
return HttpResponseRedirect(redirect_url)
try:
return super().dispatch(request, *args, **kwargs)
except (MultipleDebateTeamsError, NoDebateTeamFoundError) as e:
if hasattr(self.request, 'user') and self.request.user.is_superuser:
logger.warning("Debate team side assignment error, redirecting to tournament-fix-debate-teams")
messages.warning(request, _("You've been redirected to this page because of a problem with "
"how teams are assigned to sides in a debate."))
return redirect_tournament('tournament-fix-debate-teams', tournament)
else:
logger.warning("Debate team side assignment error, redirecting to tournament-public-index")
messages.warning(request, _("There's a problem with how teams are assigned to sides "
"in a debate. The tab director will need to resolve this issue."))
return redirect_tournament('tournament-public-index', tournament)
开发者ID:czlee,项目名称:tabbycat,代码行数:31,代码来源:mixins.py
示例9: _adjudicator_record_link
def _adjudicator_record_link(self, adj, suffix=""):
adj_short_name = adj.name.split(" ")[0]
if self.admin:
return {
'text': _("View %(a)s's %(d)s Record") % {'a': adj_short_name, 'd': suffix},
'link': reverse_tournament('participants-adjudicator-record',
self.tournament, kwargs={'pk': adj.pk})
}
elif self.tournament.pref('public_record'):
return {
'text': _("View %(a)s's %(d)s Record") % {'a': adj_short_name, 'd': suffix},
'link': reverse_tournament('participants-public-adjudicator-record',
self.tournament, kwargs={'pk': adj.pk})
}
else:
return {'text': '', 'link': False}
开发者ID:czlee,项目名称:tabbycat,代码行数:16,代码来源:tables.py
示例10: get_table
def get_table(self):
if not self.is_draw_released():
return None
debateadjs = DebateAdjudicator.objects.filter(
debate__round=self.tournament.current_round,
).select_related(
'adjudicator', 'debate__venue',
).prefetch_related(
'debate__venue__venuecategory_set',
).order_by('adjudicator__name')
table = TabbycatTableBuilder(view=self, sort_key='adj')
data = [{
'text': _("Add result from %(adjudicator)s") % {'adjudicator': da.adjudicator.name},
'link': reverse_tournament('results-public-ballotset-new-pk', self.tournament,
kwargs={'adj_id': da.adjudicator.id}),
} for da in debateadjs]
header = {'key': 'adj', 'title': _("Adjudicator")}
table.add_column(header, data)
debates = [da.debate for da in debateadjs]
table.add_debate_venue_columns(debates)
return table
开发者ID:czlee,项目名称:tabbycat,代码行数:25,代码来源:views.py
示例11: get_redirect_to
def get_redirect_to(self, use_default=True):
redirect_to = self.request.POST.get(
self.redirect_field_name,
self.request.GET.get(self.redirect_field_name, '')
)
if not redirect_to and use_default:
return reverse_tournament('tournament-admin-home', tournament=self.object)
else:
return redirect_to
开发者ID:czlee,项目名称:tabbycat,代码行数:9,代码来源:views.py
示例12: get_standings_error_message
def get_standings_error_message(self, e):
if self.request.user.is_superuser:
instructions = self.admin_standings_error_instructions
else:
instructions = self.public_standings_error_instructions
message = self.standings_error_message % {'message': str(e)}
standings_options_url = reverse_tournament('options-tournament-section', self.tournament, kwargs={'section': 'standings'})
instructions %= {'standings_options_url': standings_options_url}
return mark_safe(message + instructions)
开发者ID:czlee,项目名称:tabbycat,代码行数:10,代码来源:views.py
示例13: add_feedback_link_columns
def add_feedback_link_columns(self, adjudicators):
link_head = {
'key': 'view-feedback',
'icon': 'eye'
}
link_cell = [{
'text': 'View %s<br>feedbacks' % (len(adj.feedback_data) - 1), # -1 to account for test score
'class': 'view-feedback',
'sort': adj.debates,
'link': reverse_tournament('adjfeedback-view-on-adjudicator', self.tournament, kwargs={'pk': adj.pk})
} for adj in adjudicators]
self.add_column(link_head, link_cell)
开发者ID:czlee,项目名称:tabbycat,代码行数:12,代码来源:tables.py
示例14: get_redirect_url
def get_redirect_url(self, *args, **kwargs):
# Override if self.tournament_redirect_pattern_name is specified,
# otherwise just pass down the chain
if self.tournament_redirect_pattern_name:
try:
return reverse_tournament(self.tournament_redirect_pattern_name,
self.tournament, args=args, kwargs=kwargs)
except NoReverseMatch:
logger.warning("No Reverse Match for given tournament_slug_url_kwarg")
pass
return super().get_redirect_url(*args, **kwargs)
开发者ID:czlee,项目名称:tabbycat,代码行数:12,代码来源:mixins.py
示例15: add_debate_ballot_link_column
def add_debate_ballot_link_column(self, debates):
ballot_links_header = {'key': "ballot", 'icon': 'search'}
if self.admin:
ballot_links_data = [{
'text': _("View/Edit Ballot"),
'link': reverse_tournament('results-ballotset-edit', self.tournament, kwargs={'pk': debate.confirmed_ballot.id})
} if debate.confirmed_ballot else "" for debate in debates]
self.add_column(ballot_links_header, ballot_links_data)
elif self.tournament.pref('ballots_released'):
ballot_links_header = {'key': "ballot", 'icon': 'search'}
ballot_links_data = []
for debate in debates:
if not debate.confirmed_ballot:
ballot_links_data.append("")
elif self.tournament.pref('teams_in_debate') == 'bp' and debate.round.is_break_round:
ballot_links_data.append("")
else:
ballot_links_data.append({
'text': _("View Ballot"),
'link': reverse_tournament('results-public-scoresheet-view', self.tournament, kwargs={'pk': debate.id})
})
self.add_column(ballot_links_header, ballot_links_data)
开发者ID:czlee,项目名称:tabbycat,代码行数:24,代码来源:tables.py
示例16: post
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)
开发者ID:czlee,项目名称:tabbycat,代码行数:48,代码来源:views.py
示例17: add_breaking_checkbox
def add_breaking_checkbox(self, adjudicators, key="Breaking"):
breaking_header = {
'key': 'breaking',
'icon': 'award',
'tooltip': 'Whether the adj is marked as breaking (click to mark)',
}
breaking_data = [{
'component': 'check-cell',
'checked': adj.breaking ,
'sort': adj.breaking,
'type': 'breaking',
'saveURL': reverse_tournament('adjfeedback-set-adj-breaking-status', self.tournament),
'id': adj.pk,
} for adj in adjudicators]
self.add_column(breaking_header, breaking_data)
开发者ID:czlee,项目名称:tabbycat,代码行数:16,代码来源:tables.py
示例18: get_ballot_cells
def get_ballot_cells(self, debate, tournament, view_role, user):
# These are prefetched, so sort using Python rather than generating an SQL query
ballotsubmissions = sorted(debate.ballotsubmission_set.all(), key=lambda x: x.version)
if view_role == 'admin':
link = 'results-ballotset-new'
else:
link = 'results-assistant-ballotset-new'
return {
'component': 'ballots-cell',
'ballots': [b.serialize(tournament) for b in ballotsubmissions],
'current_user': user.username,
'acting_role': view_role,
'new_ballot': reverse_tournament(link, self.tournament,
kwargs={'debate_id': debate.id})
}
开发者ID:czlee,项目名称:tabbycat,代码行数:16,代码来源:tables.py
注:本文中的utils.misc.reverse_tournament函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论