Changeset 1528 in main for trunk


Ignore:
Timestamp:
07/20/12 08:29:44 (9 years ago)
Author:
zali
Message:

doc:typo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/templatetags/plmapp_tags.py

    r1242 r1528  
    1717    and print *dots* on the end if truncated 
    1818 
    19     :usage: ``"isome text to be truncated"|trunc:6`` 
     19    :usage: ``"some text to be truncated"|trunc:6`` 
    2020    :results: some te... 
    2121    """ 
     
    2727 
    2828@register.filter 
    29 def can_add(child, arg): 
    30     parent, action = arg 
    31  
    32     if isinstance(child, models.DocumentFile): 
    33         child = child.document 
     29def can_add(obj, arg): 
     30    """ 
     31    Test if an object can be linked to the current object. 
     32     
     33    :param obj: object to test 
     34    :type obj: it can be an instance of :class:`.DocumentFile`, :class:`.Part` or :class:`.UserController` 
     35     
     36    :param arg: arguments here are the current object and the action for link creation 
     37     
     38    :return: True if the action can be processed on the current object 
     39    """ 
     40     
     41    cur_obj, action = arg 
     42 
     43    if isinstance(obj, models.DocumentFile): 
     44        obj = obj.document 
    3445    if action == "attach_doc": 
    35         return parent.can_attach_document(child) 
     46        return cur_obj.can_attach_document(obj) 
    3647    elif action == "attach_part": 
    37         return parent.can_attach_part(child) 
     48        return cur_obj.can_attach_part(obj) 
    3849    elif action == "add_child": 
    39         return parent.can_add_child(child) 
     50        return cur_obj.can_add_child(obj) 
    4051    elif action == "delegate": 
    41         if isinstance(child, (User, UserController)): 
    42             if child.get_profile().restricted: 
     52        if isinstance(obj, (User, UserController)): 
     53            if obj.get_profile().restricted: 
    4354                return False 
    44             if hasattr(parent, "check_in_group"): 
     55            if hasattr(cur_obj, "check_in_group"): 
    4556                from django.conf import settings 
    46                 if child.username == settings.COMPANY: 
     57                if obj.username == settings.COMPANY: 
    4758                    return False 
    48                 return parent.check_in_group(child) 
     59                return cur_obj.check_in_group(obj) 
    4960            return True 
    5061    elif action == "delegate-reader": 
    51         if isinstance(child, (User, UserController)): 
    52             return child.get_profile().restricted 
     62        if isinstance(obj, (User, UserController)): 
     63            return obj.get_profile().restricted 
    5364    return False 
    5465 
    5566@register.filter 
    5667def can_add_type(parent_type, child_type): 
     68    """ 
     69    Used in Bom View. 
     70     
     71    :param parent_type: Type of the parent, the current part 
     72    :param child_type: type of the object that may be added as child 
     73     
     74    :return: True if child_type is a type of object that can be added to parent_type 
     75    """ 
    5776    c_type = models.get_all_users_and_plmobjects()[child_type] 
    5877    p_type = models.get_all_users_and_plmobjects()[parent_type] 
     
    6483@register.filter     
    6584def can_link(current_type, suggested_type): 
     85    """ 
     86    Used in Doc-Parts views. 
     87     
     88    :param current_type: type of the current object (part or document) 
     89    :param suggested_type: type of the object that may be attached to the current one 
     90     
     91    :return: True if current_type is a type of object that can be attached to current_type object 
     92    """ 
    6693    cur_type = models.get_all_users_and_plmobjects()[current_type] 
    6794    sug_type = models.get_all_users_and_plmobjects()[suggested_type] 
Note: See TracChangeset for help on using the changeset viewer.