def filebrowser(request, file_type):
    """ Trigger view for filebrowser """
    template = 'filebrowser.html'
    upload_form = FileUploadForm()
    uploaded_file = None
    upload_tab_active = False
    is_images_dialog = (file_type == 'img')
    is_documents_dialog = (file_type == 'doc')
    
    files = FileBrowserFile.objects.filter(file_type=file_type)
    
    if request.POST:
        upload_form = FileUploadForm(request.POST, request.FILES)
        upload_tab_active = True
        
        if upload_form.is_valid():
            uploaded_file = upload_form.save(commit=False)
            uploaded_file.file_type = file_type
            uploaded_file.save()
    
    data = {
        'upload_form': upload_form,
        'uploaded_file': uploaded_file,
        'upload_tab_active': upload_tab_active,
        'is_images_dialog': is_images_dialog,
        'is_documents_dialog': is_documents_dialog
    }
    per_page = getattr(settings, 'FILEBROWSER_PER_PAGE', 20)
    return render_paginate(request, template, files, per_page, data)
def filebrowser ( request , file_type ) : template = 'filebrowser.html' upload_form = FileUploadForm ( ) uploaded_file = None upload_tab_active = False is_images_dialog = ( file_type == 'img' ) is_documents_dialog = ( file_type == 'doc' ) files = FileBrowserFile . objects . filter ( file_type = file_type ) if request . POST : upload_form = FileUploadForm ( request . POST , request . FILES ) upload_tab_active = True if upload_form . is_valid ( ) : uploaded_file = upload_form . save ( commit = False ) uploaded_file . file_type = file_type uploaded_file . save ( ) data = { 'upload_form' : upload_form , 'uploaded_file' : uploaded_file , 'upload_tab_active' : upload_tab_active , 'is_images_dialog' : is_images_dialog , 'is_documents_dialog' : is_documents_dialog } per_page = getattr ( settings , 'FILEBROWSER_PER_PAGE' , 20 ) return render_paginate ( request , template , files , per_page , data )
Trigger view for filebrowser