Passed
Pull Request — 2.x (#1872)
by Jordi
06:13
created

senaite.core.catalog.indexer.baseanalysis   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A sortable_title() 0 6 2
1
# -*- coding: utf-8 -*-
2
3
from bika.lims import api
4
from bika.lims.interfaces import IBaseAnalysis
5
from plone.indexer import indexer
6
from Products.CMFPlone.utils import safe_callable
7
from senaite.core.catalog.utils import sortable_sortkey_title
8
9
10
@indexer(IBaseAnalysis)
11
def sortable_title(instance):
12
    title = sortable_sortkey_title(instance)
13
    if safe_callable(title):
14
        title = title()
15
    return "{}-{}".format(title, api.get_id(instance))
16