def get_language_hints_view(request): pi_ids = request.GET.getlist(u'pi_ids[]') filename = request.GET.get(u'filename', u'') pis = ProblemInstance.objects.filter(id__in=pi_ids) extension = get_extension(filename) lang_dict = {pi: get_language_by_extension(pi, extension) for pi in pis} if contest_exists(request): submittable_pis = submittable_problem_instances(request) lang_dict = { pi: lang for (pi, lang) in lang_dict.items() if pi in submittable_pis } else: problemsite_key = request.GET.get(u'problemsite_key', u'') lang_dict = { pi: lang for (pi, lang) in lang_dict.items() if pi.problem.problemsite.url_key == problemsite_key } langs = getattr(settings, 'SUBMITTABLE_LANGUAGES', {}) lang_display_dict = { pi.id: langs.get(lang, {'display_name': ''})['display_name'] for (pi, lang) in lang_dict.items() } return lang_display_dict
def ddzone_generator(): # show drag and drop zone only for contest with submitting some files if (not hasattr(request, 'contest') or not hasattr(request.contest, 'controller') or not isinstance(request.contest.controller, ProgrammingContestController)): return '' # do not show drag and drop zone when no available problems # (the following require controller in request) if (not has_any_submittable_problem(request) or not contest_exists(request) or not can_enter_contest(request) or getattr(request, 'hide_drag_and_drop', False)): return '' c = {'contest_id': request.contest.id} c.update(csrf(request)) return render_to_string('programs/drag_and_drop.html', c)
def ddzone_generator(): # show drag and drop zone only for contest with submitting some files if not hasattr(request, 'contest') or \ not hasattr(request.contest, 'controller') or \ not isinstance(request.contest.controller, ProgrammingContestController): return '' # do not show drag and drop zone when no available problems # (the following require controller in request) if not has_any_submittable_problem(request) \ or not contest_exists(request) \ or not can_enter_contest(request) \ or getattr(request, 'hide_drag_and_drop', False): return '' c = {'contest_id': request.contest.id} c.update(csrf(request)) return render_to_string('programs/drag_and_drop.html', c)
def _is_problem_statement_visible(self, request, pi): controller = request.contest.controller return contest_exists(request) and \ can_enter_contest(request) and \ controller.can_see_problem(request, pi) and \ controller.can_see_statement(request, pi)