endi.views.task package

Submodules

endi.views.task.pdf_rendering_service module

Task rendering service

Base service used to render Task in PDF format

class endi.views.task.pdf_rendering_service.TaskPdfFromHtmlService(context, request)

Bases : TaskRawPdfFromHtmlService

This class implements the endi.interfaces.ITaskPdfRenderingService

It extends the TaskRawPdfFromHtmlService by adding FacturX information to the generated PDF.

render()

Render the current context in pdf format

Type renvoyé:

instance of io.BytesIO

class endi.views.task.pdf_rendering_service.TaskRawPdfFromHtmlService(context, request)

Bases : object

This class implements the endi.interfaces.ITaskPdfRenderingService

filename()
render()

Render the current context in pdf format

Type renvoyé:

instance of io.BytesIO

set_task(task: Task)
Paramètres:

task (obj) – instance of Task that will replace the current context

endi.views.task.pdf_storage_service module

Pdf storage service implementation (interface ITaskPdfStorageService)

class endi.views.task.pdf_storage_service.PdfDevStorageService(context, request)

Bases : object

get_bulk_pdf(tasks)
retrieve_pdf()
set_task(task)
store_pdf(filename, pdf_buffer)
class endi.views.task.pdf_storage_service.PdfFileDepotStorageService(context, request)

Bases : object

This class implements the endi.interfaces.ITaskPdfStorageService

get_bulk_pdf(tasks)

Produce a Large pdf containing the pdf of all given tasks Excludes CGV related informations

Paramètres:

tasks (list) – List of Task instances

Renvoie:

A pdf as a bytes data buffer

retrieve_pdf()

Retrieve the pdf and returns it as a data buffer

set_task(task)

Set task (if it’s different from the current context)

store_pdf(filename, pdf_buffer)

Stores the pdf on disk if needed

Paramètres:
  • pdf_buffer (obj) – instance of io.BytesIO

  • filename (str) – The name of the pdf file

endi.views.task.rest_api module

class endi.views.task.rest_api.DiscountLineRestView(context, request=None)

Bases : BaseRestView

Rest views used to handle the task lines

Collection views : Context Task

GET

Return all the items belonging to the parent task

POST

Add a new item

Item views

GET

Return the Item

PUT/PATCH

Edit the item

DELETE

Delete the item

after_flush(entry, edit, attributes)

Allows to modify datas after the main entry was flushed

HTTP POST and PUT calls

Paramètres:
  • entry – The instance added/edited

  • edit (bool) – Is it an edition view ?

  • attributes (dict) – The validated submitted data

collection_get()

View returning the task line groups attached to this estimation

dbsession: DBSESSION
get_schema(submitted)

Return the schema for DiscountLine add/edition

Paramètres:

submitted (dict) – The submitted datas

Renvoie:

A colander.Schema

on_delete()
post_format(entry, edit, attributes)

Associate a newly created element to the parent task after edition

post_percent_discount_view()

View handling percent discount configuration

Generates discounts for each tva used in this document

current context : Invoice/Estimation/CancelInvoice

request: Request
session: ISession
class endi.views.task.rest_api.PostTTCLineRestView(context, request=None)

Bases : BaseRestView

Rest views used to handle the task lines

Collection views : Context Task

GET

Return all the items belonging to the parent task

POST

Add a new item

Item views

GET

Return the Item

PUT/PATCH

Edit the item

DELETE

Delete the item

after_flush(entry, edit, attributes)

Allows to modify datas after the main entry was flushed

HTTP POST and PUT calls

Paramètres:
  • entry – The instance added/edited

  • edit (bool) – Is it an edition view ?

  • attributes (dict) – The validated submitted data

collection_get()

View returning the task line groups attached to this estimation

dbsession: DBSESSION
get_schema(submitted)

Return the schema for PostTTCLine add/edition

Paramètres:

submitted (dict) – The submitted datas

Renvoie:

A colander.Schema

on_delete()
post_format(entry, edit, attributes)

Associate a newly created element to the parent task after edition

request: Request
session: ISession
class endi.views.task.rest_api.TaskAddRestView(context, request=None)

Bases : BaseRestView

Rest api used to add a new task

class GetParamsSchema(*args, **kw)

Bases : Schema

dbsession: DBSESSION
factory

alias de Task

form_config() dict
get_company_id() int
get_schema(submitted: Optional[dict] = None) SQLAlchemySchemaNode

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

option_urls()
put()

HTTP PUT api endpoint

request: Request
session: ISession
class endi.views.task.rest_api.TaskFileRequirementRestView(context, request=None)

Bases : BaseRestView

collection_get()
dbsession: DBSESSION
get()

End point for HTTP GET calls

request: Request
session: ISession
validation_status()
class endi.views.task.rest_api.TaskLineGroupRestView(context, request=None)

Bases : BaseRestView

Rest views handling the task line groups

Collection views : Context Task

GET

Return all the items belonging to the parent task

POST

Add a new item

Item views

GET

Return the Item

PUT/PATCH

Edit the item

DELETE

Delete the item

collection_get()

View returning the task line groups attached to this estimation

dbsession: DBSESSION
get_schema(submitted)

Return the schema for TaskLineGroup add/edition

Paramètres:

submitted (dict) – The submitted datas

Renvoie:

A colander.Schema

on_delete()
post_format(entry, edit, attributes)

Associate a newly created element to the parent task

post_load_groups_from_catalog_view()

View handling product group loading

expects sale_product_group_ids: [id1, id2] as json POST params

request: Request
session: ISession
class endi.views.task.rest_api.TaskLineRestView(context, request=None)

Bases : BaseRestView

Rest views used to handle the task lines

Collection views : Context Task

GET

Return all the items belonging to the parent task

POST

Add a new item

Item views

GET

Return the Item

PUT/PATCH

Edit the item

DELETE

Delete the item

after_flush(entry, edit, attributes)

Allows to modify datas after the main entry was flushed

HTTP POST and PUT calls

Paramètres:
  • entry – The instance added/edited

  • edit (bool) – Is it an edition view ?

  • attributes (dict) – The validated submitted data

collection_get()
dbsession: DBSESSION
get_schema(submitted)

Return the schema for TaskLine add/edition

Paramètres:

submitted (dict) – The submitted datas

Renvoie:

A colander.Schema

on_delete()
post_format(entry, edit, attributes)

Associate a newly created element to the parent group

post_load_from_catalog_view()

View handling sale_product loading

expects sale_product_ids: [id1, id2] as json POST params

request: Request
session: ISession
class endi.views.task.rest_api.TaskRestView(context, request=None)

Bases : BaseRestView

Base class for task rest api

The views contexts are instances of self.factory

Collection Views

POST

Create a new task

Item views

GET

Returns the context in json format

GET?form_config

returns the form configuration

PUT / PATCH

Edit the current element

DELETE

Delete the current element

Form Configuration ?action=form_config url

options

The available options returned to the UI

sections

Description of the different section of the form Keys provided in « sections » must be handled by the JS code.

TODO : Enhance this part to make it more generic.

after_flush(entry, edit, attributes)

Allows to modify datas after the main entry was flushed

HTTP POST and PUT calls

Paramètres:
  • entry – The instance added/edited

  • edit (bool) – Is it an edition view ?

  • attributes (dict) – The validated submitted data

dbsession: DBSESSION
factory = None
form_config()

Form display options

Renvoie:

The sections that the end user can edit, the options

available for the different select boxes

get_schema(submitted)

Return the schema for Task add/edition

Paramètres:

submitted (dict) – The submitted datas

Renvoie:

A colander.Schema

pre_format(datas, edit=False)

Allows to apply pre-formatting to the submitted datas

HTTP POST and PUT calls

Paramètres:
  • datas (dict) – The submitted datas

  • edit (bool) – Is it an edition view ?

request: Request
session: ISession
class endi.views.task.rest_api.TaskStatusLogEntryRestView(context, request=None)

Bases : StatusLogEntryRestView

dbsession: DBSESSION
get_node_url(node)

Build the url to access the given node from the notification

request: Request
session: ISession
endi.views.task.rest_api.task_total_view(context, request)

Return the Task total representation in json

Allow to avoid computing totals js side

endi.views.task.utils module

Common utilities used for task edition

endi.views.task.utils.collect_price_study_product_types()
endi.views.task.utils.get_business_types(request)
endi.views.task.utils.get_default_product_id(request, products, default_tva)

Try to find a default product_id regarding the current context

Paramètres:
  • request (obj) – A pyramid request with a Task context

  • products (list) – A list of Product instances

  • tva (obj) – The default tva

Type renvoyé:

int or None

endi.views.task.utils.get_default_tva(request, tva_options)

Return the default tva to be used in this specific context

  • The last used in the document

or - The default one

Paramètres:
  • request (obj) – The pyramid request with a Task context

  • tva_options (list) – The available options for the end user

Type renvoyé:

str

endi.views.task.utils.get_field_definition(fieldname)
endi.views.task.utils.get_mentions(request)

Collect Task mentions regarding the context’s business type

Paramètres:

request (obj) – The current request object with a Task context

Renvoie:

List of TaskMention in their json repr

endi.views.task.utils.get_payment_conditions(request)

Collect available PaymentConditions

Paramètres:

request (obj) – The current request object

Renvoie:

List of PaymentConditions

endi.views.task.utils.get_products(request)

Collect products regarding the context

Paramètres:

request (obj) – The current request object with a Task context

Renvoie:

List of Product objects

endi.views.task.utils.get_task_insurance_options(request)

Collect insurance options

endi.views.task.utils.get_task_parent_url(request, task=None, business='____none')

Returns a task parent url regarding its business type

  • all task doesn’t have a business (estimations without invoices)

  • on deleting a single invoice with no estimation, the business is deleted too,

during view execution, the task.business could point to a expired object

endi.views.task.utils.get_task_url(request, task=None, _query={}, suffix='', api=False, _anchor=None, absolute=False)

Return the route_name associated to the given Task

Paramètres:
  • request – Pyramid request

  • task – Task instance

  • _query (dict) – Query parameters

  • api (bool) – Do we ask for api url

  • _anchor (str) – Url anchor to add at the end e.g : #payment

  • absolute (bool) – Absolute url ?

endi.views.task.utils.get_task_view_type(task)

Compute the view/acl label for the given task based on its type_

endi.views.task.utils.get_tvas(request)

Collect tva objects regarding the request context

Paramètres:

request (obj) – The current request object with a Task context

Renvoie:

List of Tva objects

endi.views.task.utils.get_workunits(request)

Collect available Workunits

Paramètres:

request (obj) – The current request object

Renvoie:

List of Workunits

Return the route_name associated to the given Task

Paramètres:
  • request – Pyramid request

  • task – Task instance

endi.views.task.views module

Base Task views

class endi.views.task.views.BaseTaskHtmlTreeMixin

Bases : TreeMixin

children = []
context = None
current()
request = None
property title

str(object=””) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to “strict”.

property tree_url
class endi.views.task.views.TaskAddView(context, request=None)

Bases : BaseView

get_api_url(_query: dict = {}) str
get_list_url() str
populate_navigation()

Add buttons in the request actionmenu attribute

title = '*** Titre à modifier ***'
class endi.views.task.views.TaskDeleteView(context, request=None)

Bases : DeleteView

Base task deletion view

dbsession: DBSESSION
property delete_msg

str(object=””) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to “strict”.

msg = 'Le document {context.name} a bien été supprimé.'
on_before_delete()
on_delete()
redirect()

Return a redirect url after task deletion

request: Request
session: ISession
class endi.views.task.views.TaskDuplicateView(context, request=None)

Bases : BaseFormView

Task duplication view

before(form)

Performs some processing on the form prior 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
request: Request
schema = <endi.forms.tasks.base.DuplicateSchema object at 140624296223632 (named )>

Colander schema instance to be used to create the form instance. Provide your schema in your derived class.

session: ISession
submit_success(appstruct)
property title
class endi.views.task.views.TaskEditView(context, request=None)

Bases : BaseView, TreeMixin, TaskJsAppViewMixin

catalog_tree_url()
children = []
get_js_app_options() dict
task_line_group_api_url()
title()

str(object=””) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to “strict”.

class endi.views.task.views.TaskFilesView(context, request=None)

Bases : ProjectFilesView, BaseTaskHtmlTreeMixin

children = []
dbsession: DBSESSION
get_project_id()
route_name = ''
session: ISession
property title

str(object=””) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to “strict”.

class endi.views.task.views.TaskGeneralView(context, request=None)

Bases : BaseView, BaseTaskHtmlTreeMixin, TaskJsAppViewMixin

Base Class For the General tab of the Task html view

Subclasses should set

  • A title (str) attribute or property

  • A file_route_name (str) attribute or property pointing to the

file tab route - A route_name (str) : route presenting the current view

children = []
file_route_name: str = ''
route_name: str = ''
class endi.views.task.views.TaskJsAppViewMixin

Bases : JsAppViewMixin

context_url(_query={})
class endi.views.task.views.TaskMoveToPhaseView(context, request=None)

Bases : BaseView

View used to move a document to a specific directory/phase

expects a get arg « phase » containing the destination phase_id

class endi.views.task.views.TaskPdfDevView(context, request=None)

Bases : BaseView

Return the html structure used in pdf generation

class endi.views.task.views.TaskPdfView(context, request=None)

Bases : BaseView

Return A pdf representation of the current context

class endi.views.task.views.TaskPreviewView(context, request=None)

Bases : BaseView, BaseTaskHtmlTreeMixin

children = []
route_name = ''
class endi.views.task.views.TaskSetDraftView(context, request=None)

Bases : BaseView

Set the current task status to draft

class endi.views.task.views.TaskSetMetadatasView(context, request=None)

Bases : BaseFormView

before(form)

Performs some processing on the form prior 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).

buttons = (<deform.form.Button object>, <deform.form.Button object>)

Tuple of buttons or strings to pass to the form instance. Override in your derived class.

cancel_failure(appstruct)
cancel_success(appstruct)
dbsession: DBSESSION
redirect()
request: Request
schema = <endi.forms.tasks.base.DuplicateSchema object at 140624295264848 (named )>

Colander schema instance to be used to create the form instance. Provide your schema in your derived class.

session: ISession
submit_success(appstruct)

Handle successfull modification

Paramètres:

appstruct (dict) – The appstruct returned after form validation

Type renvoyé:

HTTPFound

property title
class endi.views.task.views.TaskSetProductsView(context, request=None)

Bases : BaseFormView

Base view for setting product codes (on invoices and cancelinvoices)

context

invoice or cancelinvoice

before(form)

Performs some processing on the form prior 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
request: Request
schema = <endi.forms.tasks.invoice.SetProductsSchema object at 140624295265488 (named )>

Colander schema instance to be used to create the form instance. Provide your schema in your derived class.

session: ISession
submit_success(appstruct)
class endi.views.task.views.TaskStatusView(context, request=None)

Bases : StatusView

View handling base status for tasks (estimation/invoice/cancelinvoice)

Status related views should implement

  • the validate function to ensure data integrity

  • state_manager_key (str) to where the status is stored on document model

check_allowed(status)

Check that the status change is allowed

Paramètres:

status (str) – The new status that should be affected

Type renvoyé:

bool

Raises:

Forbidden exception if the action isn’t allowed

dbsession: DBSESSION
get_parent_url()
get_redirect_url()

Return default URL to be redirected after status change

To be overriden

post_status_process(status, params)

Launch post status process functions

Paramètres:
  • status (str) – The new status that should be affected

  • params (dict) – The params that were transmitted by the associated

State’s callback

post_valid_process(status, params)

Launched after the status is set to valid

Paramètres:
  • status (str) – The new status that should be affected

  • params (dict) – The params that were transmitted by the associated

State’s callback

pre_status_process(status, params)

Launch pre process functions

pre_valid_process(status, params)

Launched before the valid status is set

Paramètres:
  • status (str) – The new status that should be affected

  • params (dict) – The params that were transmitted by the associated

State’s callback

pre_wait_process(status, params)

Launched before the wait status is set

Paramètres:
  • status (str) – The new status that should be affected

  • params (dict) – The params that were transmitted by the associated

State’s callback

request: Request
session: ISession
property state_manager_key: str
validate()
class endi.views.task.views.TaskZipFileView(context, request=None)

Bases : BaseZipFileView

collect_files() List[File]

Collect the File objects to include in the archive

filename()
endi.views.task.views.get_customer_redirect_btn(request, id_)

Button for « go back to customer » link

endi.views.task.views.get_project_redirect_btn(request, id_)

Button for « go back to project » link

Module contents