def assigned_list(request, slug='all', template=None):
    """Lists the assigned submissions to a Judge"""
    now = datetime.utcnow()
    filters = {
        'all': {},
        'upcoming': {
            'end_date__gte': now
        },
    }
    if not slug in filters:
        raise Http404
    queryset = filters[slug]
    ids = JudgeAssignment.objects.filter(judge=request.user.get_profile()).\
        values_list('submission__id', flat=True)
    upcoming_qs = TimeSlot.objects.\
        select_related('submission','submission__created_by').\
        filter(is_booked=True, submission__in=ids, **queryset)
    paginator = Paginator(upcoming_qs, settings.PAGINATOR_SIZE)
    page_number = get_page(request.GET)
    try:
        page = paginator.page(page_number)
    except (EmptyPage, InvalidPage):
        page = paginator.page(paginator.num_pages)
    if not template:
        template = 'webcast/judging_%s.html' % slug
    return jingo.render(request, template, {
        'page': page,
    })
Пример #2
0
def show(request, project, slug, phase, template_name='challenges/show.html',
         category=False):
    """Show an individual project challenge."""
    try:
        challenge = (Challenge.objects.select_related('project')
                     .get(project__slug=project, slug=slug))
    except Challenge.DoesNotExist:
        raise Http404
    project = challenge.project
    """Pagination options """
    entry_set = Submission.objects.visible(request.user)
    entry_set = entry_set.filter(phase__challenge=challenge, phase=phase)
    if category:
        entry_set = entry_set.filter(category__slug=category)
    page_number = get_page(request.GET)
    entries = get_paginator(entry_set, page_number, 6)
    try:
        category = Category.objects.get(slug=category)
    except ObjectDoesNotExist:
        category = False
    return jingo.render(request, template_name, {
        'challenge': challenge,
        'project': project,
        'phases': list(enumerate(challenge.phases.all(), start=1)),
        'entries': entries,
        'categories': Category.objects.get_active_categories(),
        'category': category,
        'days_remaining': phase.days_remaining,
        'phase': phase,
    })
def webcast_list(request, slug='all', template=None):
    """Lists all webcasts"""
    now = datetime.utcnow()
    filters = {
        'all': {},
        'upcoming': {
            'end_date__gte': now
        },
    }
    if not slug in filters:
        raise Http404
    queryset = filters[slug]
    upcoming_qs = TimeSlot.objects.\
        select_related('submission','submission__created_by').\
        filter(is_booked=True, **queryset)
    paginator = Paginator(upcoming_qs, settings.PAGINATOR_SIZE)
    page_number = get_page(request.GET)
    try:
        page = paginator.page(page_number)
    except (EmptyPage, InvalidPage):
        page = paginator.page(paginator.num_pages)
    context = {
        'page': page,
    }
    if not template:
        template = 'webcast/webcast_%s.html' % slug
    return jingo.render(request, template, context)
Пример #4
0
def webcast_list(request, slug='all', template=None):
    """Lists all webcasts"""
    now = datetime.utcnow()
    filters = {
        'all': {},
        'upcoming': {'end_date__gte': now},
        }
    if not slug in filters:
        raise Http404
    queryset = filters[slug]
    upcoming_qs = TimeSlot.objects.\
        select_related('submission','submission__created_by').\
        filter(is_booked=True, **queryset)
    paginator = Paginator(upcoming_qs, settings.PAGINATOR_SIZE)
    page_number = get_page(request.GET)
    try:
        page = paginator.page(page_number)
    except (EmptyPage, InvalidPage):
        page = paginator.page(paginator.num_pages)
    context = {
        'page': page,
        }
    if not template:
        template =  'webcast/webcast_%s.html' % slug
    return jingo.render(request, template, context)
Пример #5
0
def show(request, project, slug, phase, template_name='challenges/show.html',
         category=False):
    """Show an individual project challenge."""
    try:
        challenge = (Challenge.objects.select_related('project')
                     .get(project__slug=project, slug=slug))
    except Challenge.DoesNotExist:
        raise Http404
    project = challenge.project
    """Pagination options """
    entry_set = Submission.objects.visible(request.user)
    entry_set = entry_set.filter(phase__challenge=challenge, phase=phase)
    if category:
        entry_set = entry_set.filter(category__slug=category)
    page_number = get_page(request.GET)
    entries = get_paginator(entry_set, page_number, 6)
    try:
        category = Category.objects.get(slug=category)
    except ObjectDoesNotExist:
        category = False
    return jingo.render(request, template_name, {
        'challenge': challenge,
        'project': project,
        'phases': list(enumerate(challenge.phases.all(), start=1)),
        'entries': entries,
        'categories': Category.objects.get_active_categories(),
        'category': category,
        'days_remaining': phase.days_remaining,
        'phase': phase,
    })
Пример #6
0
def entry_help_list(request, project, challenge):
    """Lists all the ``Submissions`` that need help"""
    object_list = SubmissionHelp.objects.get_active()
    page_number = get_page(request.GET)
    paginated_query = get_paginator(object_list, page_number)
    context = {'page': paginated_query}
    return jingo.render(request, 'challenges/submission_help_list.html',
                        context)
Пример #7
0
def entry_help_list(request, project, challenge):
    """Lists all the ``Submissions`` that need help"""
    object_list = SubmissionHelp.objects.get_active()
    page_number = get_page(request.GET)
    paginated_query = get_paginator(object_list, page_number)
    context = {'page': paginated_query}
    return jingo.render(request, 'challenges/submission_help_list.html',
                        context)
Пример #8
0
def object_list(request, entry, release, template='timeslot/object_list.html'):
    """Listing of the ``TimeSlots`` available for a given entry"""
    # Book timeslots start at least 24 hours in advance
    start_date = datetime.utcnow() + timedelta(hours=24)
    timeslot_qs = TimeSlot.objects.filter(start_date__gte=start_date,
                                          release=release, is_booked=False)
    page_number = get_page(request.GET)
    page = get_paginator(timeslot_qs, page_number)
    context = {
        'page': page,
        'entry': entry,
        }
    return jingo.render(request, template, context)
def object_list(request, entry, release, template='timeslot/object_list.html'):
    """Listing of the ``TimeSlots`` available for a given entry"""
    # Book timeslots start at least 24 hours in advance
    start_date = datetime.utcnow() + timedelta(hours=24)
    timeslot_qs = TimeSlot.objects.filter(start_date__gte=start_date,
                                          release=release,
                                          is_booked=False)
    page_number = get_page(request.GET)
    page = get_paginator(timeslot_qs, page_number)
    context = {
        'page': page,
        'entry': entry,
    }
    return jingo.render(request, template, context)
Пример #10
0
def assigned_list(request, slug='all', template=None):
    """Lists the assigned submissions to a Judge"""
    now = datetime.utcnow()
    filters = {
        'all': {},
        'upcoming': {'end_date__gte': now},
        }
    if not slug in filters:
        raise Http404
    queryset = filters[slug]
    ids = JudgeAssignment.objects.filter(judge=request.user.get_profile()).\
        values_list('submission__id', flat=True)
    upcoming_qs = TimeSlot.objects.\
        select_related('submission','submission__created_by').\
        filter(is_booked=True, submission__in=ids, **queryset)
    paginator = Paginator(upcoming_qs, settings.PAGINATOR_SIZE)
    page_number = get_page(request.GET)
    try:
        page = paginator.page(page_number)
    except (EmptyPage, InvalidPage):
        page = paginator.page(paginator.num_pages)
    if not template:
        template =  'webcast/judging_%s.html' % slug
    return jingo.render(request, template, {'page': page,})