Changeset 1162 in main


Ignore:
Timestamp:
06/04/12 14:32:21 (7 years ago)
Author:
pcosquer
Message:

controllers: publication: adds docs

Location:
trunk/openPLM/plmapp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers/plmobject.py

    r1160 r1162  
    589589 
    590590    def check_publish(self, raise_=True): 
     591        """ 
     592        .. versionadded:: 1.1 
     593 
     594        Checks that an object can be published. 
     595 
     596        If *raise_* is True: 
     597 
     598            :raise: :exc:`.PermissionError` if the object is not official 
     599            :raise: :exc:`.PermissionError` if the user is not allowed to publish 
     600                an object (see :attr:`.UserProfile.can_publish`) 
     601            :raise: :exc:`.PermissionError` if the user does not belong to 
     602                the object's group 
     603            :raise: :exc:`.ValueError` if the object is already published 
     604 
     605        If *raise_* is False: 
     606 
     607            Returns True if all previous tests has been succesfully passed, 
     608            False otherwise. 
     609        """ 
    591610        res = self.is_official 
    592611        if (not res) and raise_: 
    593612            raise PermissionError("Invalid state: the object is not official") 
    594         res = res and self.check_in_group(raise_=raise_) 
    595613        res = res and self._user.get_profile().can_publish 
    596614        if (not res) and raise_: 
    597615            raise PermissionError("You are not allowed to publish an object") 
     616        res = res and self.check_in_group(raise_=raise_) 
    598617        res = res and not self.published 
    599618        if (not res) and raise_: 
     
    602621 
    603622    def can_publish(self): 
     623        """ 
     624        .. versionadded:: 1.1 
     625 
     626        Returns True if the user can publish this object. 
     627        """ 
    604628        return self.check_publish(raise_=False) 
    605629 
    606630    def publish(self): 
    607631        """ 
     632        .. versionadded:: 1.1 
     633 
    608634        Publish the object. 
     635         
     636        A published object can be accessed by anonymous users. 
     637 
     638        :raise: all exceptions raised by :meth:`check_publish` 
    609639        """ 
    610640        self.check_publish() 
     
    615645 
    616646    def check_unpublish(self, raise_=True): 
     647        """ 
     648        .. versionadded:: 1.1 
     649 
     650        Checks that an object can be unpublished. 
     651 
     652        If *raise_* is True: 
     653 
     654            :raise: :exc:`.PermissionError` if the user is not allowed to publish 
     655                    an object (see :attr:`.UserProfile.can_publish`) 
     656            :raise: :exc:`.PermissionError` if the user does not belong to 
     657                    the object's group 
     658            :raise: :exc:`.ValueError` if the object is not published 
     659 
     660        If *raise_* is False: 
     661 
     662            Returns True if all previous tests has been succesfully passed, 
     663            False otherwise. 
     664        """ 
     665 
    617666        res = self._user.get_profile().can_unpublish 
    618667        if (not res) and raise_: 
     
    620669        res = res and self.published 
    621670        if (not res) and raise_: 
    622             raise ValueError("Object not unpublished") 
     671            raise ValueError("Object not published") 
    623672        return res 
    624673 
    625674    def can_unpublish(self): 
     675        """ 
     676        .. versionadded:: 1.1 
     677 
     678        Returns True if the user can unpublish this object. 
     679        """ 
    626680        return self.check_unpublish(raise_=False) 
    627681 
    628682    def unpublish(self): 
    629683        """ 
     684        .. versionadded:: 1.1 
     685 
    630686        Unpublish the object. 
     687         
     688        :raise: all exceptions raised by :meth:`check_unpublish` 
    631689        """ 
    632690        self.check_unpublish() 
  • trunk/openPLM/plmapp/models.py

    r1160 r1162  
    481481            :class:`GroupInfo` that owns the object 
    482482        .. attribute:: published 
     483             
     484            .. versionadded:: 1.1 
    483485 
    484486            True if the object is published (accessible to anonymous user) 
Note: See TracChangeset for help on using the changeset viewer.