示例#1
0
def generate_problemset_tabs(request):
    tabs = []

    tabs.append({
        'name': _('Public problems'),
        'url': reverse('problemset_main')
    })

    if request.user.is_authenticated:
        tabs.append({
            'name': _('My problems'),
            'url': reverse('problemset_my_problems')
        })

        if 'oioioi.problemsharing' in settings.INSTALLED_APPS:
            if request.user.has_perm('teachers.teacher'):
                tabs.append({
                    'name': _('Shared with me'),
                    'url': reverse('problemset_shared_with_me')
                })

        if request.user.is_superuser:
            tabs.append({
                'name': _('All problems'),
                'url': reverse('problemset_all_problems')
            })
        if can_add_to_problemset(request):
            tabs.append({
                'name': _('Add problem'),
                'url': reverse('problemset_add_or_update'),
                'color': "-green"
            })

    return tabs
示例#2
0
def problemset_add_or_update_problem_view(request):
    if not can_add_to_problemset(request):
        if request.contest:
            url = reverse("add_or_update_problem") + "?" + urllib.urlencode(request.GET.dict())
            return safe_redirect(request, url)
        raise PermissionDenied

    return add_or_update_problem(request, None, "problems/problemset/add_or_update.html")
示例#3
0
def problemset_add_or_update_problem_view(request):
    if not can_add_to_problemset(request):
        if request.contest:
            url = reverse('add_or_update_problem') + '?' + \
                six.moves.urllib.parse.urlencode(request.GET.dict())
            return safe_redirect(request, url)
        raise PermissionDenied

    return add_or_update_problem(request, None,
                                 'problems/problemset/add-or-update.html')
示例#4
0
def problemset_add_or_update_problem_view(request):
    if not can_add_to_problemset(request):
        if request.contest:
            url = reverse('add_or_update_problem') + '?' + \
                six.moves.urllib.parse.urlencode(request.GET.dict())
            return safe_redirect(request, url)
        raise PermissionDenied

    return add_or_update_problem(request, None,
                                 'problems/problemset/add-or-update.html')
示例#5
0
def can_add_to_problemset_processor(request):
    return {'can_add_to_problemset': can_add_to_problemset(request)}
示例#6
0
def can_add_to_problemset_processor(request):
    return {'can_add_to_problemset': can_add_to_problemset(request)}