Sujet précédent

5.1.5. controllers.base — Base class for controllers

Sujet suivant

5.1.7. controllers.group — Controllers for groups

Cette page

Autres langues

5.1.6. controllers.document — Controllers for documents

class plmapp.controllers.document.DocumentController(obj, user, block_mails=False, no_index=False)[source]

Bases: openPLM.plmapp.controllers.plmobject.PLMObjectController

A PLMObjectController which manages Document

It provides methods to add or delete files, (un)lock them and attach a Document to a Part.

classmethod create_from_form(form, user, *args, **kwargs)[source]

Returns True if settings.ENABLE_NATIVE_FILE_MANAGEMENT is True and exists a document that contains a standard locked file related to the file we want to add.

We use it to avoid to add a native file while a related standard locked file is present in the document.

Paramètres:new_filename – name of the added file
check_edit_files()[source]
lock(doc_file)[source]

Lock doc_file so that it can not be modified or deleted if doc_file has a native related file this will be deprecated

Exceptions raised:
 
Paramètres:

doc_file (DocumentFile) –

unlock(doc_file)[source]

Unlock doc_file so that it can be modified or deleted

Exceptions raised:
 
  • ValueError if doc_file.document is not self.object
  • plmapp.exceptions.UnlockError if doc_file is already unlocked or doc_file.locker is not the current user
Paramètres:

doc_file (DocumentFile) –

add_file(f, update_attributes=True, thumbnail=True)[source]

Adds file f to the document. f should be a File with an attribute name (like an UploadedFile).

If update_attributes is True (the default), handle_added_file() will be called with f as parameter.

Retourne:the DocumentFile created.
Raises :PermissionError if _user is not the owner of object
Raises :PermissionError if object is not editable.
Raises :ValueError if the file size is superior to settings.MAX_FILE_SIZE
Raises :ValueError if we try to add a native file while a relate standar file locked is present in the Document
add_thumbnail(doc_file, thumbnail_file)[source]

Sets thumnail_file as the thumbnail of doc_file. thumbnail_file should be a File with an attribute name (like an UploadedFile).

Exceptions raised:
 
delete_file(doc_file)[source]

Deletes doc_file, the file attached to doc_file is physically removed.

Exceptions raised:
 
Paramètres:

doc_file (DocumentFile) – the file to be deleted

handle_added_file(doc_file)[source]

Method called when adding a file (method add_file()) with updates_attributes set to True.

This method may be overridden to updates attributes with data from doc_file. The default implementation does nothing.

Paramètres:doc_file (DocumentFile) –
attach_to_part(part)[source]

Links part (a Part) with object.

detach_part(part)[source]

Deletes link between part (a Part) and object.

get_attached_parts(time=None)[source]

Returns all parts attached to object.

get_detachable_parts()[source]

Returns all attached parts the user can detach.

is_part_attached(part)[source]

Returns True if part is attached to the current document.

check_attach_part(part, detach=False)[source]
can_attach_part(part)[source]

Returns True if part can be attached to the current document.

can_detach_part(part)[source]

Returns True if part can be detached.

get_suggested_parts()[source]

Returns a QuerySet of parts a user may want to attach to a future revision.

revise(new_revision, selected_parts=(), **kwargs)[source]
checkin(doc_file, new_file, update_attributes=True, thumbnail=True)[source]

Updates doc_file with data from new_file. doc_file.thumbnail is deleted if it is present.

Exceptions raised:
 
Paramètres:
update_rel_part(formset)[source]

Updates related part informations with data from formset

Paramètres:formset (a modelfactory_formset of ModifyRelPartForm) –
update_file(formset)[source]

Updates uploaded file informations with data from formset

Paramètres:formset (a modelfactory_formset of ModifyFileForm) –
Raises :PermissionError if _user is not the owner of object
Raises :PermissionError if object is not editable.
cancel()[source]

Cancels the object:

check_cancel(raise_=True)[source]
clone(form, user, parts, block_mails=False, no_index=False)[source]

Clones the object :

Paramètres:parts – list of Part selected to be attached to the new document

Return true if the document is attached to at least one part.

publish()[source]
unpublish()[source]
promote(*args, **kwargs)[source]
demote(*args, **kwargs)[source]
object