Exemple #1
0
    def test_create_judge(self):
        """ Test creating a judge. """
        judge = Judge(competition=self.competition,
                      username="******",
                      password="******",
                      email="*****@*****.**")
        judge.save()

        self.assertIsNotNone(judge)
Exemple #2
0
def get_judges(request):
    last_online_time = Judge.last_online_time()
    if request.user.is_superuser or request.user.is_staff:
        return True, list(chain(Judge.objects.filter(last_ping__gte=last_online_time),
                                Judge.objects.exclude(last_ping__gte=last_online_time)))
    else:
        return False, Judge.objects.filter(last_ping__gte=last_online_time)
Exemple #3
0
 def get_context_data(self, **kwargs):
     context = super(LanguageJudgesAjaxList,
                     self).get_context_data(**kwargs)
     context['judges'] = Judge.objects.filter(
         runtimes__key=self.lang,
         last_ping__gte=Judge.last_online_time()).order_by('load')
     return context
Exemple #4
0
 def __init__(self, *args, **kwargs):
     super(ProblemSubmitForm, self).__init__(*args, **kwargs)
     self.fields['problem'].empty_label = None
     self.fields['problem'].widget = forms.HiddenInput()
     self.fields['language'].empty_label = None
     self.fields['language'].label_from_instance = attrgetter('display_name')
     self.fields['language'].queryset = Language.objects.filter(
             judges__last_ping__gte=Judge.last_online_time()).distinct()
Exemple #5
0
def status_table(request):
    see_all, judges = get_judges(request)
    return render(
        request, 'status/judge-status-table.html', {
            'judges': judges,
            'runtime_version_data': Judge.runtime_versions(),
            'see_all_judges': see_all,
        })
Exemple #6
0
def get_judges(request):
    last_online_time = Judge.last_online_time()
    if request.user.is_superuser or request.user.is_staff:
        return True, list(
            chain(Judge.objects.filter(last_ping__gte=last_online_time),
                  Judge.objects.exclude(last_ping__gte=last_online_time)))
    else:
        return False, Judge.objects.filter(last_ping__gte=last_online_time)
Exemple #7
0
def status_all(request):
    see_all, judges = get_judges(request)
    return render(
        request, 'status/judge-status.html', {
            'title': _('Status'),
            'judges': judges,
            'runtime_version_data': Judge.runtime_versions(),
            'see_all_judges': see_all,
        })
Exemple #8
0
 def __init__(self, *args, **kwargs):
     super(ProblemSubmitForm, self).__init__(*args, **kwargs)
     self.fields['problem'].empty_label = None
     self.fields['problem'].widget = forms.HiddenInput()
     self.fields['language'].empty_label = None
     self.fields['language'].label_from_instance = attrgetter(
         'display_name')
     self.fields['language'].queryset = Language.objects.filter(
         judges__last_ping__gte=Judge.last_online_time()).distinct()
Exemple #9
0
 def get_context_data(self, **kwargs):
     context = super(LanguageJudgesAjaxList, self).get_context_data(**kwargs)
     context["judges"] = Judge.objects.filter(
         runtimes__key=self.lang, last_ping__gte=Judge.last_online_time()
     ).order_by("load")
     return context
Exemple #10
0
 def get_context_data(self, **kwargs):
     context = super(LanguageDetail, self).get_context_data(**kwargs)
     context["judges"] = self.object.judges.filter(last_ping__gte=Judge.last_online_time()).order_by("load")
     return context
Exemple #11
0
 def handle(self, *args, **options):
     judge = Judge()
     judge.name = options['name']
     judge.auth_key = options['auth_key']
     judge.save()
Exemple #12
0
 def get_context_data(self, **kwargs):
     context = super(LanguageDetail, self).get_context_data(**kwargs)
     context['judges'] = self.object.judges.filter(
         last_ping__gte=Judge.last_online_time()).order_by('load')
     return context