Conditions | 1 |
Total Lines | 76 |
Code Lines | 63 |
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(ClientsView, self).__init__(context, request) |
||
38 | |||
39 | self.contentFilter = { |
||
40 | "portal_type": "Client", |
||
41 | "sort_on": "sortable_title", |
||
42 | "sort_order": "ascending" |
||
43 | } |
||
44 | |||
45 | self.title = self.context.translate(_("Clients")) |
||
46 | |||
47 | self.show_select_column = True |
||
48 | self.show_select_all_checkbox = False |
||
49 | |||
50 | self.context_actions = { |
||
51 | _("Add"): { |
||
52 | "url": "createObject?type_name=Client", |
||
53 | 'permission': AddPortalContent, |
||
54 | "icon": "add.png" |
||
55 | } |
||
56 | } |
||
57 | |||
58 | self.columns = collections.OrderedDict(( |
||
59 | ("title", { |
||
60 | "title": _("Name"), |
||
61 | "index": "sortable_title"},), |
||
62 | ("getClientID", { |
||
63 | "title": _("Client ID")}), |
||
64 | ("EmailAddress", { |
||
65 | "title": _("Email Address"), |
||
66 | "sortable": False}), |
||
67 | ("getCountry", { |
||
68 | "toggle": False, |
||
69 | "sortable": False, |
||
70 | "title": _("Country")}), |
||
71 | ("getProvince", { |
||
72 | "toggle": False, |
||
73 | "sortable": False, |
||
74 | "title": _("Province")}), |
||
75 | ("getDistrict", { |
||
76 | "toggle": False, |
||
77 | "sortable": False, |
||
78 | "title": _("District")}), |
||
79 | ("Phone", { |
||
80 | "title": _("Phone"), |
||
81 | "sortable": False}), |
||
82 | ("Fax", { |
||
83 | "toggle": False, |
||
84 | "sortable": False, |
||
85 | "title": _("Fax")}), |
||
86 | ("BulkDiscount", { |
||
87 | "toggle": False, |
||
88 | "sortable": False, |
||
89 | "title": _("Bulk Discount")}), |
||
90 | ("MemberDiscountApplies", { |
||
91 | "toggle": False, |
||
92 | "sortable": False, |
||
93 | "title": _("Member Discount")}), |
||
94 | )) |
||
95 | |||
96 | self.review_states = [ |
||
97 | { |
||
98 | "id": "default", |
||
99 | "contentFilter": {"review_state": "active"}, |
||
100 | "title": _("Active"), |
||
101 | "columns": self.columns.keys(), |
||
102 | }, { |
||
103 | "id": "inactive", |
||
104 | "title": _("Inactive"), |
||
105 | "contentFilter": {"review_state": "inactive"}, |
||
106 | "columns": self.columns.keys(), |
||
107 | }, { |
||
108 | "id": "all", |
||
109 | "title": _("All"), |
||
110 | "contentFilter": {}, |
||
111 | "columns": self.columns.keys(), |
||
112 | }, |
||
154 |