def METHOD_NAME(request, doc_id):
    doc = get_object_or_404(Document, id=doc_id)
    doc_user = doc.comment.user
    if request.user.is_staff or doc_user == request.user:
        filename = os.path.basename(doc.docfile.name)
        if is_acceptable_image_type(filename):
            image_file = doc.docfile
            video_file = None
        elif is_acceptable_vid_type(filename):
            image_file = None
            video_file = doc.docfile
        else:
            raise Http404("Unsupported image or video format.  See your teacher if"
                          " you think this format should be supported.")
        portfolio, created = Portfolio.objects.get_or_create(user=doc_user)
        Artwork.create(
            title=os.path.splitext(filename)[0][:50],
            image_file=image_file,
            video_file=video_file,
            portfolio=portfolio,
            date=doc.comment.timestamp.date(),
        )
        return redirect('portfolios:detail', pk=portfolio.pk)
    else:
        raise Http404("I don't think you're supposed to be here....")