Conditions | 1 |
Total Lines | 81 |
Code Lines | 58 |
Lines | 81 |
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 -*- |
||
34 | View Code Duplication | def __init__(self, context, request): |
|
|
|||
35 | super(SubGroupsView, self).__init__(context, request) |
||
36 | |||
37 | self.catalog = SETUP_CATALOG |
||
38 | self.show_select_column = True |
||
39 | |||
40 | self.contentFilter = { |
||
41 | "portal_type": "SubGroup", |
||
42 | "sort_on": "sortable_title", |
||
43 | "sort_order": "ascending", |
||
44 | "path": { |
||
45 | "query": api.get_path(self.context), |
||
46 | "depth": 1, |
||
47 | } |
||
48 | } |
||
49 | |||
50 | self.context_actions = { |
||
51 | _("listing_subgroup_action_add", default="Add"): { |
||
52 | "url": "++add++SubGroup", |
||
53 | "permission": AddSubGroup, |
||
54 | "icon": "senaite_theme/icon/plus" |
||
55 | } |
||
56 | } |
||
57 | |||
58 | self.title = translate(_( |
||
59 | "listing_subgroups_title", |
||
60 | default="Sub-Groups") |
||
61 | ) |
||
62 | self.description = "" |
||
63 | self.icon = api.get_icon("SubGroups", html_tag=False) |
||
64 | |||
65 | self.columns = collections.OrderedDict(( |
||
66 | ("Title", { |
||
67 | "title": _( |
||
68 | "listing_subgroups_column_title", |
||
69 | default="Title" |
||
70 | ), |
||
71 | "index": "sortable_title"}), |
||
72 | ("Description", { |
||
73 | "title": _( |
||
74 | "listing_subgroups_column_description", |
||
75 | default="Description" |
||
76 | ), |
||
77 | "toggle": True, |
||
78 | }), |
||
79 | ("SortKey", { |
||
80 | "title": _( |
||
81 | "listing_subgroups_column_sortkey", |
||
82 | default="Sort Key" |
||
83 | ), |
||
84 | "toggle": True, |
||
85 | }), |
||
86 | )) |
||
87 | |||
88 | self.review_states = [ |
||
89 | { |
||
90 | "id": "default", |
||
91 | "title": _( |
||
92 | "listing_subgroups_state_active", |
||
93 | default="Active" |
||
94 | ), |
||
95 | "contentFilter": {"is_active": True}, |
||
96 | "transitions": [{"id": "deactivate"}, ], |
||
97 | "columns": self.columns.keys(), |
||
98 | }, { |
||
99 | "id": "inactive", |
||
100 | "title": _( |
||
101 | "listing_subgroups_state_inactive", |
||
102 | default="Inactive" |
||
103 | ), |
||
104 | "contentFilter": {'is_active': False}, |
||
105 | "transitions": [{"id": "activate"}, ], |
||
106 | "columns": self.columns.keys(), |
||
107 | }, { |
||
108 | "id": "all", |
||
109 | "title": _( |
||
110 | "listing_subgroups_state_all", |
||
111 | default="All" |
||
112 | ), |
||
113 | "contentFilter": {}, |
||
114 | "columns": self.columns.keys(), |
||
115 | }, |
||
124 |