Changeset 1043 in main


Ignore:
Timestamp:
04/26/12 07:41:25 (7 years ago)
Author:
pcosquer
Message:

search panel: allow to add a document matched by a file if relevant

Location:
trunk/openPLM
Files:
2 edited

Legend:

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

    r997 r1043  
    2828    parent, action = arg 
    2929 
     30    if isinstance(child, models.DocumentFile): 
     31        child = child.document 
    3032    if action == "attach_doc": 
    3133        return parent.can_attach_document(child) 
     
    7779def is_plmobject(result): 
    7880    """ 
    79     Returns True if the object behind *result* is an instance of :class:`PLMObject.` 
     81    Returns True if the object behind *result* is an instance of :class:`.PLMObject` 
    8082    """ 
    8183    return issubclass(result.model, models.PLMObject) 
     84 
     85@register.filter 
     86def is_documentfile(result): 
     87    """ 
     88    Returns True if the object behind *result* is an instance of :class:`.DocumentFile` 
     89    """ 
     90    return issubclass(result.model, models.DocumentFile) 
    8291 
    8392@models._cache_lifecycle_stuff 
     
    104113    Returns a css class according to result. 
    105114    """ 
    106     if issubclass(result.model, models.PLMObject): 
     115    if issubclass(result.model, (models.PLMObject, models.DocumentFile)): 
    107116        result.state_id = result.state 
    108117        result.lifecycle_id = result.lifecycle 
    109         return "state-" + get_state_class(result) 
     118        if result.state_id and result.lifecycle_id: 
     119            return "state-" + get_state_class(result) 
    110120    return "" 
    111121 
  • trunk/openPLM/templates/search/result.html

    r995 r1043  
    33<li class="Result {{result|result_class}}"> 
    44{% if navigate_bool %} 
    5     {% if result|is_plmobject %} 
     5    {% if result|is_plmobject or result|is_documentfile %} 
    66        <div class="toolbar"> 
    77            <button class="attach">{% trans "Attach" %}</button> 
Note: See TracChangeset for help on using the changeset viewer.