| Conditions | 1 | 
| Total Lines | 72 | 
| Code Lines | 51 | 
| 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 -*- | ||
| 34 | def __init__(self, context, request): | ||
| 35 | super(SamplingDeviationsView, self).__init__(context, request) | ||
| 36 | |||
| 37 | self.catalog = SETUP_CATALOG | ||
| 38 |         self.contentFilter = { | ||
| 39 | "portal_type": "SamplingDeviation", | ||
| 40 | "sort_on": "sortable_title", | ||
| 41 | "sort_order": "ascending", | ||
| 42 |             "path": { | ||
| 43 | "query": api.get_path(self.context), | ||
| 44 | "depth": 1, | ||
| 45 | }, | ||
| 46 | } | ||
| 47 | |||
| 48 |         self.context_actions = { | ||
| 49 |             _("listing_samplingdeviations_action_add", default="Add"): { | ||
| 50 | "url": "++add++SamplingDeviation", | ||
| 51 | "permission": AddSamplingDeviation, | ||
| 52 | "icon": "senaite_theme/icon/plus" | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | self.title = translate(_( | ||
| 57 | "listing_samplingdeviations_title", | ||
| 58 | default="Sampling Deviations") | ||
| 59 | ) | ||
| 60 |         self.icon = api.get_icon("SamplingDeviations", html_tag=False) | ||
| 61 | self.show_select_column = True | ||
| 62 | |||
| 63 | self.columns = collections.OrderedDict(( | ||
| 64 |             ("Title", { | ||
| 65 | "title": _( | ||
| 66 | "listing_samplingdeviations_column_title", | ||
| 67 | default="Sampling Deviation", | ||
| 68 | ), | ||
| 69 | "index": "sortable_title", | ||
| 70 | }), | ||
| 71 |             ("Description", { | ||
| 72 | "title": _( | ||
| 73 | "listing_samplingdeviations_column_description", | ||
| 74 | default="Description", | ||
| 75 | ), | ||
| 76 | "index": "Description", | ||
| 77 | "toggle": True, | ||
| 78 | }), | ||
| 79 | )) | ||
| 80 | |||
| 81 | self.review_states = [ | ||
| 82 |             { | ||
| 83 | "id": "default", | ||
| 84 | "title": _( | ||
| 85 | "listing_samplingdeviations_state_all", | ||
| 86 | default="All", | ||
| 87 | ), | ||
| 88 |                 "contentFilter": {}, | ||
| 89 | "columns": self.columns.keys(), | ||
| 90 |             }, { | ||
| 91 | "id": "active", | ||
| 92 | "title": _( | ||
| 93 | "listing_samplingdeviations_state_active", | ||
| 94 | default="Active", | ||
| 95 | ), | ||
| 96 |                 "contentFilter": {"is_active": True}, | ||
| 97 | "columns": self.columns.keys(), | ||
| 98 |             }, { | ||
| 99 | "id": "inactive", | ||
| 100 | "title": _( | ||
| 101 | "listing_samplingdeviations_state_inactive", | ||
| 102 | default="Inactive", | ||
| 103 | ), | ||
| 104 |                 "contentFilter": {'is_active': False}, | ||
| 105 | "columns": self.columns.keys(), | ||
| 106 | } | ||
| 123 |