Conditions | 1 |
Total Lines | 86 |
Code Lines | 60 |
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(SuppliersView, self).__init__(context, request) |
||
38 | |||
39 | self.catalog = SETUP_CATALOG |
||
40 | |||
41 | self.contentFilter = { |
||
42 | "portal_type": "Supplier", |
||
43 | "sort_on": "sortable_title", |
||
44 | "sort_order": "ascending", |
||
45 | "path": { |
||
46 | "query": api.get_path(self.context), |
||
47 | "depth": 1, |
||
48 | }, |
||
49 | } |
||
50 | |||
51 | self.context_actions = { |
||
52 | _("listing_suppliers_action_add", default="Add"): { |
||
53 | "url": "++add++Supplier", |
||
54 | "permission": AddSupplier, |
||
55 | "icon": "senaite_theme/icon/plus" |
||
56 | } |
||
57 | } |
||
58 | |||
59 | self.title = translate(_( |
||
60 | "listing_suppliers_title", |
||
61 | default="Suppliers") |
||
62 | ) |
||
63 | self.icon = api.get_icon("Suppliers", html_tag=False) |
||
64 | self.show_select_column = True |
||
65 | |||
66 | self.columns = collections.OrderedDict(( |
||
67 | ("Name", { |
||
68 | "title": _( |
||
69 | u"listing_suppliers_column_name", |
||
70 | default=u"Name", |
||
71 | ), |
||
72 | "index": "sortable_title", |
||
73 | }), |
||
74 | ("Email", { |
||
75 | "title": _( |
||
76 | u"listing_suppliers_column_email", |
||
77 | default=u"Email" |
||
78 | ), |
||
79 | "toggle": True, |
||
80 | }), |
||
81 | ("Phone", { |
||
82 | "title": _( |
||
83 | u"listing_suppliers_column_phone", |
||
84 | default=u"Phone" |
||
85 | ), |
||
86 | "toggle": True, |
||
87 | }), |
||
88 | ("Fax", { |
||
89 | "title": _( |
||
90 | u"listing_suppliers_column_fax", |
||
91 | default=u"Fax" |
||
92 | ), |
||
93 | "toggle": True, |
||
94 | }), |
||
95 | )) |
||
96 | |||
97 | self.review_states = [ |
||
98 | { |
||
99 | "id": "default", |
||
100 | "title": _( |
||
101 | u"listing_suppliers_state_active", |
||
102 | default=u"Active" |
||
103 | ), |
||
104 | "contentFilter": {"is_active": True}, |
||
105 | "columns": self.columns.keys(), |
||
106 | }, { |
||
107 | "id": "inactive", |
||
108 | "title": _( |
||
109 | u"listing_suppliers_state_inactive", |
||
110 | default=u"Inactive" |
||
111 | ), |
||
112 | "contentFilter": {'is_active': False}, |
||
113 | "columns": self.columns.keys(), |
||
114 | }, { |
||
115 | "id": "all", |
||
116 | "title": _( |
||
117 | u"listing_suppliers_state_all", |
||
118 | default=u"All" |
||
119 | ), |
||
120 | "contentFilter": {}, |
||
121 | "columns": self.columns.keys(), |
||
122 | }, |
||
140 |