Conditions | 1 |
Total Lines | 78 |
Code Lines | 67 |
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 -*- |
||
43 | def __init__(self, context, request): |
||
44 | super(ClientFolderContentsView, self).__init__(context, request) |
||
45 | |||
46 | self.title = self.context.translate(_("Clients")) |
||
47 | self.description = "" |
||
48 | self.form_id = "list_clientsfolder" |
||
49 | self.sort_on = "sortable_title" |
||
50 | # Landing page to be added to the link of each client from the list |
||
51 | self.landing_page = get_registry_value( |
||
52 | self._LANDING_PAGE_REGISTRY_KEY, self._DEFAULT_LANDING_PAGE) |
||
53 | |||
54 | self.catalog = CLIENT_CATALOG |
||
55 | self.contentFilter = { |
||
56 | "portal_type": "Client", |
||
57 | "sort_on": "sortable_title", |
||
58 | "sort_order": "ascending" |
||
59 | } |
||
60 | |||
61 | self.icon = "{}/{}".format( |
||
62 | self.portal_url, "++resource++bika.lims.images/client_big.png") |
||
63 | |||
64 | self.columns = collections.OrderedDict(( |
||
65 | ("title", { |
||
66 | "title": _("Name"), |
||
67 | "index": "sortable_title"},), |
||
68 | ("ClientID", { |
||
69 | "title": _("Client ID")}), |
||
70 | ("EmailAddress", { |
||
71 | "title": _("Email Address"), |
||
72 | "sortable": False}), |
||
73 | ("Country", { |
||
74 | "toggle": False, |
||
75 | "sortable": False, |
||
76 | "title": _("Country")}), |
||
77 | ("Province", { |
||
78 | "toggle": False, |
||
79 | "sortable": False, |
||
80 | "title": _("Province")}), |
||
81 | ("District", { |
||
82 | "toggle": False, |
||
83 | "sortable": False, |
||
84 | "title": _("District")}), |
||
85 | ("Phone", { |
||
86 | "title": _("Phone"), |
||
87 | "sortable": False}), |
||
88 | ("Fax", { |
||
89 | "toggle": False, |
||
90 | "sortable": False, |
||
91 | "title": _("Fax")}), |
||
92 | ("BulkDiscount", { |
||
93 | "toggle": False, |
||
94 | "sortable": False, |
||
95 | "title": _("Bulk Discount")}), |
||
96 | ("MemberDiscount", { |
||
97 | "toggle": False, |
||
98 | "sortable": False, |
||
99 | "title": _("Member Discount")}), |
||
100 | )) |
||
101 | |||
102 | self.review_states = [ |
||
103 | { |
||
104 | "id": "default", |
||
105 | "contentFilter": {"review_state": "active"}, |
||
106 | "title": _("Active"), |
||
107 | "transitions": [{"id": "deactivate"}, ], |
||
108 | "columns": self.columns.keys(), |
||
109 | }, { |
||
110 | "id": "inactive", |
||
111 | "title": _("Inactive"), |
||
112 | "contentFilter": {"review_state": "inactive"}, |
||
113 | "transitions": [{"id": "activate"}, ], |
||
114 | "columns": self.columns.keys(), |
||
115 | }, { |
||
116 | "id": "all", |
||
117 | "title": _("All"), |
||
118 | "contentFilter": {}, |
||
119 | "transitions": [], |
||
120 | "columns": self.columns.keys(), |
||
121 | }, |
||
209 |