endi.views.files package¶
Submodules¶
endi.views.files.rest_api module¶
Rest api for file management
- GET /api/v1/nodes/:node_id/files¶
Returns a list of files attached to the given node
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 123, "label": "My file", "name": "My file", "size": 1024, "human_size": "1ko", "mimetype": "application/octet-stream", "description": "My file is very important", "created_at": "12/05/2023", "updated_at": "18/05/2023", "file_type_id": 12, "parent_id": 12, }, ... ]
- POST /api/v1/nodes/:node_id/files¶
Add a file to the given node (or switch it to another regarding the parameters)
In case an indicator_id is given we will try to attach the file to the given
indicator and to its node - In case a file_type_id is given we will try to find an indicator to attach the file to (going also on upper levels)
- Paramètres de la forme:
name – name of the file
description – description of the file
upload – File object
file_type_id – the FileType’s id
indicator_id – Optional Indicator’s id
- POST /api/v1/files/¶
Add a file
- Paramètres de la forme:
parent_id – the parent’s id
name – name of the file
description – description of the file
upload – File object
file_type_id – the FileType’s id
indicator_id – Optional Indicator’s id
- GET /api/v1/files/:id¶
Return a specific file
HTTP/1.1 200 OK Content-Type: application/json { "id": 123, "label": "My file", "name": "My file", "size": 1024, "human_size": "1ko", "mimetype": "application/octet-stream", "description": "My file is very important", "created_at": "12/05/2023", "updated_at": "18/05/2023", "file_type_id": 12, "parent_id": 12, }
- PUT /api/v1/files/:id¶
Allows to edit a specific file
- Paramètres de la forme:
parent_id – the parent’s id
name – name of the file
description – description of the file
upload – File object
file_type_id – the FileType’s id
indicator_id – Optional Indicator’s id
- class endi.views.files.rest_api.FileRestView(context, request=None)¶
Bases :
BaseRestViewBase rest view for accessing files
- dbsession: DBSESSION¶
- delete()¶
HTTP DELETE api endpoint
- get_schema(submitted: dict)¶
Build the colander schema to be used
- Paramètres:
submitted – Data submitted to the api endpoint
- Renvoie:
A form schema used to validate the submitted data
- move_view()¶
Get the node id from the request json body, retrieve the Node instance and check if the user has permission to add a file to the node then move the file to this node
- query()¶
- request: Request¶
- session: ISession¶
- class endi.views.files.rest_api.NodeFileRestView(context, request=None)¶
Bases :
FileRestViewCommon Rest entry point for all node parents
- collection_get()¶
- dbsession: DBSESSION¶
- request: Request¶
- session: ISession¶
- endi.views.files.rest_api.includeme(config)¶
endi.views.files.routes module¶
- endi.views.files.routes.includeme(config)¶
Add module’s related routes
endi.views.files.views module¶
- class endi.views.files.views.BaseZipFileView(context, request=None)¶
Bases :
BaseViewBase Zip File View, allows to produce an archive with multiple files
E.g :
- class endi.views.files.views.FileDeleteView(context, request=None)¶
Bases :
DeleteView,FileViewRedirectMixina class:endi.events.files.FileDeleted is fired on file deletion
- dbsession: DBSESSION¶
- delete()¶
- delete_msg = None¶
- redirect()¶
- request: Request¶
- session: ISession¶
- class endi.views.files.views.FileEditView(context, request=None)¶
Bases :
FileUploadViewView for file object modification
Current context is the file itself
a class:endi.events.files.FileUpdated is fired on file modification
- before(form)¶
Performs some processing on the
formprior to rendering.By default, this method does nothing. Override this method in your dervived class to modify the
form. Your function will be executed immediately after instansiating the form instance in__call__()(thus before obtaining widget resources, considering buttons, or rendering).
- dbsession: DBSESSION¶
- edit = True¶
- request: Request¶
- session: ISession¶
- property title¶
The form title
- valid_msg = 'Le fichier a bien été enregistré'¶
- class endi.views.files.views.FileUploadView(context, request=None)¶
Bases :
BaseFormViewForm view for file upload
Current context for this view is the document the file should be attached to (Invoice, Estimation…)
By getting the referrer url from the request object, we provide the redirection to the original page when the file is added
a class:endi.events.files.FileAdded is fired on file modification
- before(form)¶
Performs some processing on the
formprior to rendering.By default, this method does nothing. Override this method in your dervived class to modify the
form. Your function will be executed immediately after instansiating the form instance in__call__()(thus before obtaining widget resources, considering buttons, or rendering).
- dbsession: DBSESSION¶
- edit = False¶
- redirect(come_from)¶
Build the redirection url
Can be overriden to specify a redirection
- request: Request¶
- schema = <endi.forms.files.FileUploadSchema object at 140624326164624 (named )>¶
Colander schema instance to be used to create the form instance. Provide your schema in your derived class.
- session: ISession¶
- submit_success(appstruct)¶
Insert data in the database
- title = 'Téléverser un fichier'¶
- class endi.views.files.views.FileView(context, request=None)¶
Bases :
BaseView,FileViewRedirectMixinA base file view allowing to tune the way datas is shown
- delete_url()¶
- download_url()¶
- edit_url()¶
- get_file_path(action)¶
- class endi.views.files.views.FileViewRedirectMixin¶
Bases :
PopupMixinMixin providing tools to handle redirection from within a File related view
- NODE_TYPE_LABEL = {'activity': 'au rendez-vous', 'business': "à l'affaire", 'cancelinvoice': "à l'avoir", 'estimation': 'au devis', 'expensesheet': 'à la note de dépenses', 'internalcancelinvoice': "à l'avoir interne", 'internalestimation': 'au devis interne', 'internalinvoice': 'à la facture interne', 'internalsupplier_invoice': 'à la facture fournisseur interne', 'internalsupplier_order': 'à la commande fournisseur interne', 'invoice': 'à la facture', 'project': 'au dossier', 'supplier_invoice': 'à la facture fournisseur', 'supplier_order': 'à la commande fournisseur', 'userdata': 'à la fiche de gestion sociale', 'workshop': "à l'atelier"}¶
- NODE_TYPE_ROUTES = {'activity': 'activity', 'business': '/businesses/{id}/files', 'cancelinvoice': '/cancelinvoices/{id}', 'estimation': '/estimations/{id}', 'expensesheet': '/expenses/{id}', 'internalcancelinvoice': '/cancelinvoices/{id}', 'internalestimation': '/estimations/{id}', 'internalinvoice': '/invoices/{id}', 'internalsupplier_invoice': '/supplier_invoices/{id}', 'internalsupplier_order': '/supplier_orders/{id}', 'invoice': '/invoices/{id}', 'project': '/projects/{id}/files', 'supplier_invoice': '/supplier_invoices/{id}', 'supplier_order': '/supplier_orders/{id}', 'trainerdata': '/trainerdatas/{id}/filelist', 'userdata': '/users/{id}/userdatas/filelist', 'workshop': 'workshop'}¶
- back_url()¶
- get_label()¶
- get_redirect_item()¶
- endi.views.files.views.file_dl_view(context, request)¶
download view for a given file
- endi.views.files.views.file_stream_view(context, request)¶
download view for a given file
- endi.views.files.views.get_add_file_link(request, label='Attacher un fichier', perm='add.file', route=None)¶
Add a button for file attachment
- endi.views.files.views.includeme(config)¶
Configure views
Module contents¶
- endi.views.files.includeme(config)¶