uploads : Managing uploaded files

The lino.modliblib.uploads plugin adds functionality for managing "uploads".

A tested document

This is a tested document. The following instructions are used for initialization:

>>> from lino import startup
>>> startup('lino_book.projects.min9.settings.doctests')
>>> from lino.api.doctest import *

Uploads

class lino.modlib.uploads.Upload

Django model representing an upload.

type

The type of this upload.

Pointer to UploadType. The choices for this field are usually limited to those in the same upload area.

file

Pointer to the uploaded file. See lino.mixins.uploadable.Uploadable.file

description

A short description entered manually by the user.

Almost the same as description, but if file is not empty, the text is clickable, and clicking on it opens the uploaded file in a new browser window.

class lino.modlib.uploads.AreaUploads

Mixin for tables of uploads where the area is known. Inherited by UploadsByController.

The summary displays the uploads related to this controller as a list grouped by uploads type.

Note that this also works on lino_welfare.modlib.uploads.models.UploadsByClient and their subclasses for the different _upload_area.

class lino.modlib.uploads.MyUploads

Shows my uploads (i.e. those whose author is the current user).

class lino.modlib.uploads.UploadsByController

Shows the uploads controlled by this database object.

Upload areas

The application developper can define upload areas. Every upload area has its list of upload types. The default has only one upload area.

>>> rt.show(uploads.UploadAreas)
======= ========= =========
 value   name      text
------- --------- ---------
 90      general   Uploads
======= ========= =========

For example Lino Welfare extends this list.

Upload types

class lino.modlib.uploads.UploadType

The type of an upload.

shortcut

Optional pointer to a virtual upload shortcut field. If this is not empty, then the given shortcut field will manage uploads of this type. See also Shortcuts.

class lino.modlib.uploads.UploadTypes

The table with all existing upload types.

This usually is accessible via the Configure menu.

UploadController

class lino.modlib.uploads.UploadController
show_uploads(self, obj, ar=None)

Show uploads in a grid table.

🖿

Upload shortcuts

The application developper can define upload shortcuts. Every upload shortcut will create an upload shortcut field, a virtual field with a set of actions for quickly uploading or viewing uploads of a particular type for a given database object.

Usage:

  • Declare your Site's upload shortcuts from within your workflows_module. For example:

    from lino.modlib.uploads.choicelists import add_shortcut as add
    add('contacts.Person', 'uploaded_foos', _("Foos"))
    
  • Using the web interface, select Configure ‣ Office ‣ Upload types, create an upload type named "Foo" and set its shortcut field to "Foos".

  • Upload a file from your PC to the server.

  • Open the uploaded file in a new browser window

class lino.modlib.uploads.Shortcuts

The list of upload shortcut fields which have been declared on this Site.

>>> rt.show(uploads.Shortcuts)
No data to display
lino.modlib.uploads.add_shortcut(*args, **kw)

Declare an upload shortcut field. This is designed to be called from within your workflows_module.