Exemple #1
0
def problem_site_files(request, problem):
    additional_files = attachment_registry_problemset.to_list(request=request,
                                                              problem=problem)
    files_qs = ProblemAttachment.objects.filter(problem=problem.id)
    files = sorted(
        [{
            'name':
            f.filename,
            'description':
            f.description,
            'link':
            reverse(
                'problem_site_external_attachment',
                kwargs={
                    'site_key': problem.problemsite.url_key,
                    'attachment_id': f.id,
                },
            ),
        } for f in files_qs],
        key=itemgetter('name'),
    )
    files.extend(additional_files)

    return TemplateResponse(
        request,
        'problems/files.html',
        {
            'files': files,
            'files_on_page': getattr(settings, 'FILES_ON_PAGE', 100),
            'add_category_field': False,
        },
    )
Exemple #2
0
def check_for_downloads(request, problem):
    """Function checking if given problem has any downloadables."""
    return bool(ProblemAttachment.objects.filter(problem=problem)) or \
           bool(attachment_registry_problemset.to_list(request=request, problem=problem))