Conditions | 1 |
Total Lines | 80 |
Code Lines | 56 |
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(SamplePointsView, self).__init__(context, request) |
||
36 | |||
37 | self.catalog = SETUP_CATALOG |
||
38 | self.show_select_column = True |
||
39 | |||
40 | self.contentFilter = { |
||
41 | "portal_type": "SamplePoint", |
||
42 | "sort_on": "sortable_title", |
||
43 | "sort_order": "ascending", |
||
44 | "path": { |
||
45 | "query": api.get_path(context), |
||
46 | "level": 0, |
||
47 | } |
||
48 | } |
||
49 | |||
50 | self.context_actions = { |
||
51 | _(u"listing_samplepoints_action_add", default=u"Add"): { |
||
52 | "url": "++add++SamplePoint", |
||
53 | "permission": AddSamplePoint, |
||
54 | "icon": "senaite_theme/icon/plus" |
||
55 | } |
||
56 | } |
||
57 | |||
58 | self.title = translate(_( |
||
59 | u"listing_samplepoints_title", |
||
60 | default=u"Sample Points") |
||
61 | ) |
||
62 | self.icon = api.get_icon("SamplePoints", html_tag=False) |
||
63 | |||
64 | self.columns = collections.OrderedDict(( |
||
65 | ("Title", { |
||
66 | "title": _( |
||
67 | u"listing_samplepoints_column_title", |
||
68 | default=u"Sample Point" |
||
69 | ), |
||
70 | "index": "sortable_title" |
||
71 | }), |
||
72 | ("Description", { |
||
73 | "title": _( |
||
74 | u"listing_samplepoints_column_description", |
||
75 | default=u"Description" |
||
76 | ), |
||
77 | "toggle": True |
||
78 | }), |
||
79 | ("SampleTypes", { |
||
80 | "title": _( |
||
81 | u"listing_samplepoints_column_sampletypes", |
||
82 | default=u"Sample Types", |
||
83 | ), |
||
84 | "index": "sampletype_title", |
||
85 | "sortable": True, |
||
86 | }), |
||
87 | )) |
||
88 | |||
89 | self.review_states = [ |
||
90 | { |
||
91 | "id": "default", |
||
92 | "title": _( |
||
93 | u"listing_samplepoints_state_active", |
||
94 | default=u"Active" |
||
95 | ), |
||
96 | "contentFilter": {"is_active": True}, |
||
97 | "columns": self.columns.keys(), |
||
98 | }, { |
||
99 | "id": "inactive", |
||
100 | "title": _( |
||
101 | u"listing_samplepoints_state_inactive", |
||
102 | default=u"Inactive" |
||
103 | ), |
||
104 | "contentFilter": {"is_active": False}, |
||
105 | "columns": self.columns.keys(), |
||
106 | }, { |
||
107 | "id": "all", |
||
108 | "title": _( |
||
109 | u"listing_samplepoints_state_all", |
||
110 | default=u"All" |
||
111 | ), |
||
112 | "contentFilter": {}, |
||
113 | "columns": self.columns.keys(), |
||
114 | }, |
||
128 |