def generator(): is_admin = request.user.has_perm('contests.contest_admin', request.contest) messages = visible_messages(request) if is_admin: messages = messages.filter(message__isnull=True, top_reference__isnull=True, kind='QUESTION') else: messages = new_messages(request, messages) count = messages.count() if count: template = Template(TEMPLATE) text = ungettext('%(count)d NEW MESSAGE', '%(count)d NEW MESSAGES', count) % {'count': count} if count == 1: message = messages.get() link = reverse('message', kwargs={ 'contest_id': request.contest.id, 'message_id': message.top_reference_id or message.id }) else: link = reverse('contest_messages', kwargs={'contest_id': request.contest.id}) html = template.render(Context({'link': link, 'text': text})) return html else: return ''
def generator(): is_admin = request.user.has_perm('contests.contest_admin', request.contest) messages = visible_messages(request) if is_admin: messages = messages.filter(message__isnull=True, top_reference__isnull=True, kind='QUESTION') else: messages = new_messages(request, messages) count = messages.count() if count: template = Template(TEMPLATE) text = ungettext('%(count)d NEW MESSAGE', '%(count)d NEW MESSAGES', count) % { 'count': count } if count == 1: message = messages.get() link = reverse('message', kwargs={ 'contest_id': request.contest.id, 'message_id': message.top_reference_id or message.id }) else: link = reverse('contest_messages', kwargs={'contest_id': request.contest.id}) html = template.render(Context({'link': link, 'text': text})) return html else: return ''
def contest_dashboard_view(request, contest_id): top_links = grouper(3, top_links_registry.template_context(request)) submissions = Submission.objects \ .filter(problem_instance__contest=request.contest) \ .order_by('-date').select_related() controller = request.contest.controller submissions = controller.filter_visible_submissions(request, submissions) submissions = submissions[:getattr(settings, 'NUM_DASHBOARD_SUBMISSIONS', 8)] submissions = [submission_template_context(request, s) for s in submissions] show_scores = bool(s for s in submissions if s.score is not None) messages = messages_template_context(request, visible_messages(request)) context = { 'top_links': top_links, 'submissions': submissions, 'records': messages, 'show_scores': show_scores } return TemplateResponse(request, 'dashboard/dashboard.html', context)
def contest_dashboard_view(request, contest_id): top_links = grouper(3, top_links_registry.template_context(request)) submissions = Submission.objects \ .filter(problem_instance__contest=request.contest) \ .order_by('-date').select_related() controller = request.contest.controller submissions = controller.filter_visible_submissions(request, submissions) submissions = submissions[:getattr(settings, 'NUM_DASHBOARD_SUBMISSIONS', 8 )] submissions = [ submission_template_context(request, s) for s in submissions ] show_scores = bool(s for s in submissions if s.score is not None) messages = messages_template_context(request, visible_messages(request)) context = { 'top_links': top_links, 'submissions': submissions, 'records': messages, 'show_scores': show_scores } return TemplateResponse(request, 'dashboard/dashboard.html', context)