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 -*- |
||
22 | def __init__(self, context, request): |
||
23 | super(BatchFolderContentsView, self).__init__(context, request) |
||
24 | |||
25 | self.catalog = "bika_catalog" |
||
26 | self.contentFilter = { |
||
27 | "portal_type": "Batch", |
||
28 | "sort_on": "created", |
||
29 | "sort_order": "descending", |
||
30 | "cancellation_state": "active" |
||
31 | } |
||
32 | |||
33 | self.context_actions = {} |
||
34 | |||
35 | self.show_select_all_checkbox = False |
||
36 | self.show_select_column = True |
||
37 | self.pagesize = 30 |
||
38 | |||
39 | batch_image_path = "/++resource++bika.lims.images/batch_big.png" |
||
40 | self.icon = "{}{}".format(self.portal_url, batch_image_path) |
||
41 | self.title = self.context.translate(_("Batches")) |
||
42 | self.description = "" |
||
43 | |||
44 | self.columns = collections.OrderedDict(( |
||
45 | ("Title", { |
||
46 | "title": _("Title"), |
||
47 | "index": "title", }), |
||
48 | ("BatchID", { |
||
49 | "title": _("Batch ID"), |
||
50 | "index": "getId", }), |
||
51 | ("Description", { |
||
52 | "title": _("Description"), |
||
53 | "sortable": False, }), |
||
54 | ("BatchDate", { |
||
55 | "title": _("Date"), }), |
||
56 | ("Client", { |
||
57 | "title": _("Client"), |
||
58 | "index": "getClientTitle", }), |
||
59 | ("ClientID", { |
||
60 | "title": _("Client ID"), |
||
61 | "index": "getClientID", }), |
||
62 | ("ClientBatchID", { |
||
63 | "title": _("Client Batch ID"), |
||
64 | "index": "getClientBatchID", }), |
||
65 | ("state_title", { |
||
66 | "title": _("State"), |
||
67 | "sortable": False, }), |
||
68 | ("created", { |
||
69 | "title": _("Created"), |
||
70 | "index": "created", |
||
71 | }), |
||
72 | )) |
||
73 | |||
74 | self.review_states = [ |
||
75 | { |
||
76 | "id": "default", |
||
77 | "contentFilter": {"review_state": "open"}, |
||
78 | "title": _("Open"), |
||
79 | "transitions": [{"id": "close"}, {"id": "cancel"}], |
||
80 | "columns": self.columns.keys(), |
||
81 | }, { |
||
82 | "id": "closed", |
||
83 | "contentFilter": {"review_state": "closed"}, |
||
84 | "title": _("Closed"), |
||
85 | "transitions": [{"id": "open"}], |
||
86 | "columns": self.columns.keys(), |
||
87 | }, { |
||
88 | "id": "cancelled", |
||
89 | "title": _("Cancelled"), |
||
90 | "transitions": [{"id": "reinstate"}], |
||
91 | "contentFilter": {"cancellation_state": "cancelled"}, |
||
92 | "columns": self.columns.keys(), |
||
93 | }, { |
||
94 | "id": "all", |
||
95 | "title": _("All"), |
||
96 | "transitions": [], |
||
97 | "columns": self.columns.keys(), |
||
98 | }, |
||
171 |