Conditions | 1 |
Total Lines | 66 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
34 | def __init__(self, context, request): |
||
35 | super(SampleMatricesView, self).__init__(context, request) |
||
36 | |||
37 | self.catalog = SETUP_CATALOG |
||
38 | self.show_select_column = True |
||
39 | |||
40 | self.contentFilter = { |
||
41 | "portal_type": "SampleMatrix", |
||
42 | "sort_on": "sortable_title", |
||
43 | "sort_order": "ascending", |
||
44 | } |
||
45 | |||
46 | self.context_actions = { |
||
47 | _(u"listing_samplematrices_action_add", default=u"Add"): { |
||
48 | "url": "++add++SampleMatrix", |
||
49 | "permission": AddSampleMatrix, |
||
50 | "icon": "senaite_theme/icon/plus" |
||
51 | } |
||
52 | } |
||
53 | |||
54 | self.title = translate(_( |
||
55 | u"listing_samplematrices_title", |
||
56 | default=u"Sample Matrices") |
||
57 | ) |
||
58 | self.icon = api.get_icon("SampleMatrices", html_tag=False) |
||
59 | |||
60 | self.columns = collections.OrderedDict(( |
||
61 | ("Title", { |
||
62 | "title": _( |
||
63 | u"listing_samplematrices_column_title", |
||
64 | default=u"Sample Matrix" |
||
65 | ), |
||
66 | "index": "sortable_title"}), |
||
67 | ("Description", { |
||
68 | "title": _( |
||
69 | u"listing_samplematrices_column_description", |
||
70 | default=u"Description" |
||
71 | ), |
||
72 | "toggle": True}), |
||
73 | )) |
||
74 | |||
75 | self.review_states = [ |
||
76 | { |
||
77 | "id": "default", |
||
78 | "title": _( |
||
79 | u"listing_samplematrices_state_active", |
||
80 | default=u"Active" |
||
81 | ), |
||
82 | "contentFilter": {"is_active": True}, |
||
83 | "columns": self.columns.keys(), |
||
84 | }, { |
||
85 | "id": "inactive", |
||
86 | "title": _( |
||
87 | u"listing_samplematrices_state_inactive", |
||
88 | default=u"Inactive" |
||
89 | ), |
||
90 | "contentFilter": {"is_active": False}, |
||
91 | "columns": self.columns.keys(), |
||
92 | }, { |
||
93 | "id": "all", |
||
94 | "title": _( |
||
95 | u"listing_samplematrices_state_all", |
||
96 | default=u"All" |
||
97 | ), |
||
98 | "contentFilter": {}, |
||
99 | "columns": self.columns.keys(), |
||
100 | }, |
||
106 |