Conditions | 1 |
Total Lines | 77 |
Code Lines | 54 |
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 -*- |
||
36 | def __init__(self, context, request): |
||
37 | super(AnalysisProfilesView, self).__init__(context, request) |
||
38 | |||
39 | self.catalog = SETUP_CATALOG |
||
40 | self.show_select_column = True |
||
41 | |||
42 | self.contentFilter = { |
||
43 | "portal_type": "AnalysisProfile", |
||
44 | "sort_on": "sortable_title", |
||
45 | "sort_order": "ascending", |
||
46 | } |
||
47 | |||
48 | self.context_actions = { |
||
49 | _(u"listing_analysisprofiles_action_add", default=u"Add"): { |
||
50 | "url": "++add++AnalysisProfile", |
||
51 | "permission": AddAnalysisProfile, |
||
52 | "icon": "senaite_theme/icon/plus" |
||
53 | } |
||
54 | } |
||
55 | |||
56 | self.title = translate(_( |
||
57 | u"listing_analysisprofiles_title", |
||
58 | default=u"Analysis Profiles") |
||
59 | ) |
||
60 | self.icon = api.get_icon("AnalysisProfiles", html_tag=False) |
||
61 | |||
62 | self.columns = collections.OrderedDict(( |
||
63 | ("Title", { |
||
64 | "title": _( |
||
65 | u"listing_analysisprofiles_column_title", |
||
66 | default=u"Profile" |
||
67 | ), |
||
68 | "index": "sortable_title", |
||
69 | }), |
||
70 | ("Description", { |
||
71 | "title": _( |
||
72 | u"listing_analysisprofiles_column_description", |
||
73 | default=u"Description" |
||
74 | ), |
||
75 | "index": "Description", |
||
76 | "toggle": True, |
||
77 | }), |
||
78 | ("ProfileKey", { |
||
79 | "title": _( |
||
80 | u"listing_analysisprofiles_column_profilekey", |
||
81 | default=u"Profile Key" |
||
82 | ), |
||
83 | "sortable": False, |
||
84 | "toggle": True, |
||
85 | }), |
||
86 | )) |
||
87 | |||
88 | self.review_states = [ |
||
89 | { |
||
90 | "id": "default", |
||
91 | "title": _( |
||
92 | u"listing_analysisprofiles_state_active", |
||
93 | default=u"Active" |
||
94 | ), |
||
95 | "contentFilter": {"is_active": True}, |
||
96 | "columns": self.columns.keys(), |
||
97 | }, { |
||
98 | "id": "inactive", |
||
99 | "title": _( |
||
100 | u"listing_analysisprofiles_state_inactive", |
||
101 | default=u"Inactive" |
||
102 | ), |
||
103 | "contentFilter": {'is_active': False}, |
||
104 | "columns": self.columns.keys(), |
||
105 | }, { |
||
106 | "id": "all", |
||
107 | "title": _( |
||
108 | u"listing_analysisprofiles_state_all", |
||
109 | default=u"All" |
||
110 | ), |
||
111 | "contentFilter": {}, |
||
112 | "columns": self.columns.keys(), |
||
113 | }, |
||
121 |