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