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