Conditions | 1 |
Total Lines | 72 |
Code Lines | 51 |
Lines | 72 |
Ratio | 100 % |
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(DynamicAnalysisSpecsView, self).__init__(context, request) |
||
38 | |||
39 | self.catalog = SETUP_CATALOG |
||
40 | |||
41 | self.contentFilter = { |
||
42 | "portal_type": "DynamicAnalysisSpec", |
||
43 | "sort_on": "created", |
||
44 | "sort_order": "descending", |
||
45 | "path": { |
||
46 | "query": api.get_path(self.context), |
||
47 | "depth": 1, |
||
48 | }, |
||
49 | } |
||
50 | |||
51 | self.context_actions = { |
||
52 | _("listing_dynamic_analysisspec_action_add", default="Add"): { |
||
53 | "url": "++add++DynamicAnalysisSpec", |
||
54 | "permission": AddAnalysisSpec, |
||
55 | "icon": "senaite_theme/icon/plus" |
||
56 | } |
||
57 | } |
||
58 | |||
59 | self.icon = api.get_icon("DynamicAnalysisSpecs", html_tag=False) |
||
60 | |||
61 | self.title = translate(_( |
||
62 | u"listing_dynamic_analysisspecs_title", |
||
63 | default=u"Dynamic Analysis Specifications") |
||
64 | ) |
||
65 | self.description = self.context.Description() |
||
66 | self.show_select_column = True |
||
67 | |||
68 | self.columns = collections.OrderedDict(( |
||
69 | ("Title", { |
||
70 | "title": _( |
||
71 | u"listing_dynamic_analysisspecs_column_title", |
||
72 | default=u"Title" |
||
73 | ), |
||
74 | "index": "sortable_title"}), |
||
75 | ("Description", { |
||
76 | "title": _( |
||
77 | u"listing_dynamic_analysisspecs_column_description", |
||
78 | default=u"Description" |
||
79 | ), |
||
80 | "toggle": True}), |
||
81 | )) |
||
82 | |||
83 | self.review_states = [ |
||
84 | { |
||
85 | "id": "default", |
||
86 | "title": _( |
||
87 | u"listing_dynamic_analysisspecs_state_active", |
||
88 | default=u"Active" |
||
89 | ), |
||
90 | "contentFilter": {"is_active": True}, |
||
91 | "columns": self.columns.keys(), |
||
92 | }, { |
||
93 | "id": "inactive", |
||
94 | "title": _( |
||
95 | u"listing_dynamic_analysisspecs_state_inactive", |
||
96 | default=u"Inactive" |
||
97 | ), |
||
98 | "contentFilter": {"is_active": False}, |
||
99 | "columns": self.columns.keys(), |
||
100 | }, { |
||
101 | "id": "all", |
||
102 | "title": _( |
||
103 | u"listing_dynamic_analysisspecs_state_all", |
||
104 | default=u"All" |
||
105 | ), |
||
106 | "contentFilter": {}, |
||
107 | "columns": self.columns.keys(), |
||
108 | }, |
||
121 |