Conditions | 1 |
Total Lines | 81 |
Code Lines | 69 |
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 -*- |
||
38 | def __init__(self, context, request): |
||
39 | super(BatchFolderContentsView, self).__init__(context, request) |
||
40 | |||
41 | self.catalog = SENAITE_CATALOG |
||
42 | self.contentFilter = { |
||
43 | "portal_type": "Batch", |
||
44 | "sort_on": "created", |
||
45 | "sort_order": "descending", |
||
46 | "is_active": True, |
||
47 | } |
||
48 | |||
49 | self.title = self.context.translate(_("Batches")) |
||
50 | self.description = "" |
||
51 | |||
52 | self.show_select_column = True |
||
53 | self.form_id = "batches" |
||
54 | self.context_actions = {} |
||
55 | self.icon = "{}{}".format(self.portal_url, "/senaite_theme/icon/batch") |
||
56 | |||
57 | self.columns = collections.OrderedDict(( |
||
58 | ("Title", { |
||
59 | "title": _("Title"), |
||
60 | "index": "title", }), |
||
61 | ("Progress", { |
||
62 | "title": _("Progress"), |
||
63 | "index": "getProgress", |
||
64 | "sortable": True, |
||
65 | "toggle": True}), |
||
66 | ("BatchID", { |
||
67 | "title": _("Batch ID"), |
||
68 | "index": "getId", }), |
||
69 | ("BatchLabels", { |
||
70 | "title": _("Batch Labels"), |
||
71 | "sortable": False, }), |
||
72 | ("Description", { |
||
73 | "title": _("Description"), |
||
74 | "sortable": False, }), |
||
75 | ("BatchDate", { |
||
76 | "title": _("Date"), }), |
||
77 | ("Client", { |
||
78 | "title": _("Client"), |
||
79 | "index": "getClientTitle", }), |
||
80 | ("ClientID", { |
||
81 | "title": _("Client ID"), |
||
82 | "index": "getClientID", }), |
||
83 | ("ClientBatchID", { |
||
84 | "title": _("Client Batch ID"), |
||
85 | "index": "getClientBatchID", }), |
||
86 | ("state_title", { |
||
87 | "title": _("State"), |
||
88 | "sortable": False, }), |
||
89 | ("created", { |
||
90 | "title": _("Created"), |
||
91 | "index": "created", |
||
92 | }), |
||
93 | )) |
||
94 | |||
95 | self.review_states = [ |
||
96 | { |
||
97 | "id": "default", |
||
98 | "contentFilter": {"review_state": "open"}, |
||
99 | "title": _("Open"), |
||
100 | "transitions": [], |
||
101 | "columns": self.columns.keys(), |
||
102 | }, { |
||
103 | "id": "closed", |
||
104 | "contentFilter": {"review_state": "closed"}, |
||
105 | "title": _("Closed"), |
||
106 | "transitions": [], |
||
107 | "columns": self.columns.keys(), |
||
108 | }, { |
||
109 | "id": "cancelled", |
||
110 | "title": _("Cancelled"), |
||
111 | "transitions": [], |
||
112 | "contentFilter": {"is_active": False}, |
||
113 | "columns": self.columns.keys(), |
||
114 | }, { |
||
115 | "id": "all", |
||
116 | "title": _("All"), |
||
117 | "transitions": [], |
||
118 | "columns": self.columns.keys(), |
||
119 | }, |
||
224 |