Table des matières

Sujet précédent

8. Bill of materials – BOM

Sujet suivant

10. Rich text | Wiki syntax

Cette page

Autres langues

9. Publication

Introduit dans la version 1.1.

This document describes how the Publication specification is implemented.

9.1. Publishers

A new boolean field UserProfile.can_publish is added to each UserProfile. By default, this field is set to False. If this field is set to True, the user can publish an object (if all other rules are respected).

The migration plmapp/migrations/0014_auto__add_field_userprofile_can_publish.py adds this field (set to False) to all existing users.

This field is neither a creation field nor a modification field. Only an admin can modify this field via the admin interface.

9.2. Model

9.2.1. PLMObject

A new boolean field PLMObject.published is added to each PLMObject. By default, this field is set to False. If this field is set to True, it means the object has been published and is accessible to anonymous users.

The migration plmapp/migrations/0015_auto__add_field_plmobject_published.py adds this field (set to False) to all existing plmobjects.

A new property named PLMObject.published_attributes returns the list of published attributes. By default, it returns the following attributes:

  1. type
  2. reference
  3. revision
  4. name

This property can be overriden by a custom model to add more attributes.

9.2.2. History

All publication and unpublication are stored in the History table.

A publication is stored with the AbstractHistory.action field set to Publish.

A unpublication is stored with the AbstractHistory.action field set to Unpublish.

9.3. Controller

9.3.1. Publishing a document

9.3.1.1. Methods

The following methods are available to publish a PLMObject and test if a PLMObject can be published:

9.3.1.2. Tests

  • ControllerTest.test_publish_not_official()
  • ControllerTest.test_publish_official()
  • ControllerTest.test_publish_deprecated()
  • ControllerTest.test_publish_published()
  • ControllerTest.test_publish_not_publisher()
  • ControllerTest.test_publish_not_in_group()

9.3.2. Unpublishing a document

9.3.2.1. Methods

The following methods are available to unpublish a PLMObject and test if a PLMObject can be unpublished:

9.3.2.2. Tests

  • ControllerTest.test_unpublish_not_official()
  • ControllerTest.test_unpublish_official()
  • ControllerTest.test_unpublish_deprecated()
  • ControllerTest.test_unpublish_published()
  • ControllerTest.test_unpublish_not_publisher()
  • ControllerTest.test_unpublish_not_in_group()

9.4. Views

9.4.1. Lifecycle

display_object_lifecycle() handles the publication and unpublication of a PLMObject.

9.4.1.1. Tests

  • ViewTest.test_publish_post()
  • ViewTest.test_publish_post_error_not_official()
  • ViewTest.test_publish_post_error_published()
  • ViewTest.test_unpublish_post()
  • ViewTest.test_unpublish_post_error_unpublished()

9.4.2. Public

public() view renders a published PLMObject. If the given object is not published, it redirects to the login page. If the given object is neither a part nor a document, it raises an Http404 exception.

9.4.2.1. Tests

  • ViewTest.test_public_get()
  • ViewTest.test_public_error()

9.4.3. Public download

public_download() handles the download of a published file.

9.4.4. Browse

browse() allows an anonymous user to browse all published parts and documents.

9.5. Templates

9.5.1. lifecycle.html

If an object has been published, this template displays a link to its publish page.

If the user can publish the object, it adds a form named form-publish that prompts the user password and warns the user that a published object is accessible to anonymous user.

If the user can unpublish the object, it adds a form named form-unpublish that prompts the user password and warns the user that a unpublished object is no more accessible to anonymous user.

9.5.2. public.html

If the object has been published, this template displays:

  • all non deprecated files
  • all published attributes
  • the state of the object
  • all published revisions
  • all published attached parts and documents

9.5.3. browse.html

If the user is not authenticated, it hides all unaccessible objects (users, groups, unpublished object).