Passed
Push — master ( e3f582...5930d4 )
by Ramon
03:43
created

SampleMatricesView.folderitem()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 4
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.CORE.
4
#
5
# SENAITE.CORE is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free Software
7
# Foundation, version 2.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 51
16
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
#
18
# Copyright 2018-2020 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
from bika.lims import bikaMessageFactory as _
22
from bika.lims.browser.bika_listing import BikaListingView
23
from bika.lims.config import PROJECTNAME
24
from bika.lims.interfaces import ISampleMatrices
25
from bika.lims.permissions import AddSampleMatrix
26
from bika.lims.utils import get_link
27
from plone.app.folder.folder import ATFolder
28
from plone.app.folder.folder import ATFolderSchema
29
from Products.Archetypes import atapi
30
from Products.ATContentTypes.content import schemata
31
from zope.interface.declarations import implements
32
33
34
class SampleMatricesView(BikaListingView):
35
36
    def __init__(self, context, request):
37
        super(SampleMatricesView, self).__init__(context, request)
38
        self.catalog = 'bika_setup_catalog'
39
        self.contentFilter = {'portal_type': 'SampleMatrix',
40
                              'sort_on': 'sortable_title'}
41
        self.context_actions = {_('Add'): {
42
            'url': 'createObject?type_name=SampleMatrix',
43
            'permission': AddSampleMatrix,
44
            'icon': '++resource++bika.lims.images/add.png'
45
        }}
46
        self.title = self.context.translate(_("Sample Matrices"))
47
        self.icon = self.portal_url + \
48
                    "/++resource++bika.lims.images/samplematrix_big.png"
49
        self.description = ""
50
51
        self.show_select_row = False
52
        self.show_select_column = True
53
        self.pagesize = 25
54
55
        self.columns = {
56
            'Title': {'title': _('Sample Matrix'),
57
                      'index': 'sortable_title'},
58
            'Description': {'title': _('Description'),
59
                            'index': 'description',
60
                            'toggle': True},
61
        }
62
63
        self.review_states = [
64
            {'id': 'default',
65
             'title': _('All'),
66
             'contentFilter': {},
67
             'transitions': [{'id': 'empty'}, ],
68
             'columns': ['Title', 'Description']},
69
            {'id': 'active',
70
             'title': _('Active'),
71
             'contentFilter': {'is_active': True},
72
             'transitions': [{'id': 'deactivate'}, ],
73
             'columns': ['Title', 'Description']},
74
            {'id': 'inactive',
75
             'title': _('Inactive'),
76
             'contentFilter': {'is_active': False},
77
             'transitions': [{'id': 'activate'}, ],
78
             'columns': ['Title', 'Description']}
79
        ]
80
81
    def before_render(self):
82
        """Before template render hook
83
        """
84
        # Don't allow any context actions
85
        self.request.set("disable_border", 1)
86
87
    def folderitem(self, obj, item, index):
88
        item["replace"]["Title"] = get_link(item["url"], item["Title"])
89
        return item
90
91
92
schema = ATFolderSchema.copy()
93
94
95
class SampleMatrices(ATFolder):
96
    implements(ISampleMatrices)
97
    displayContentsTab = False
98
    schema = schema
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable schema does not seem to be defined.
Loading history...
99
100
101
schemata.finalizeATCTSchema(schema, folderish=True, moveDiscussion=False)
102
atapi.registerType(SampleMatrices, PROJECTNAME)
103