| Conditions | 1 |
| Total Lines | 65 |
| Code Lines | 45 |
| Lines | 65 |
| 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 -*- |
||
| 34 | def __init__(self, context, request): |
||
| 35 | super(BatchLabelsView, self).__init__(context, request) |
||
| 36 | |||
| 37 | self.catalog = SETUP_CATALOG |
||
| 38 | |||
| 39 | self.contentFilter = { |
||
| 40 | "portal_type": "BatchLabel", |
||
| 41 | "sort_on": "sortable_title", |
||
| 42 | "sort_order": "ascending", |
||
| 43 | "path": { |
||
| 44 | "query": api.get_path(context), |
||
| 45 | "depth": 1, |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | self.context_actions = { |
||
| 50 | _("listing_batchlabels_action_add", default="Add"): { |
||
| 51 | "url": "++add++BatchLabel", |
||
| 52 | "permission": AddBatchLabel, |
||
| 53 | "icon": "senaite_theme/icon/plus" |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | self.title = translate(_( |
||
| 58 | "listing_batchlabels_title", |
||
| 59 | default="Batch Labels") |
||
| 60 | ) |
||
| 61 | |||
| 62 | self.icon = api.get_icon("BatchLabels", html_tag=False) |
||
| 63 | self.description = "" |
||
| 64 | |||
| 65 | self.columns = collections.OrderedDict(( |
||
| 66 | ("Title", { |
||
| 67 | "title": _( |
||
| 68 | u"listing_batchlabels_column_title", |
||
| 69 | default=u"Title" |
||
| 70 | ), |
||
| 71 | "index": "sortable_title"}), |
||
| 72 | )) |
||
| 73 | |||
| 74 | self.review_states = [ |
||
| 75 | { |
||
| 76 | "id": "default", |
||
| 77 | "title": _( |
||
| 78 | u"listing_batchlabels_state_active", |
||
| 79 | default=u"Active" |
||
| 80 | ), |
||
| 81 | "contentFilter": {"is_active": True}, |
||
| 82 | "columns": self.columns.keys(), |
||
| 83 | }, { |
||
| 84 | "id": "inactive", |
||
| 85 | "title": _( |
||
| 86 | u"listing_batchlabels_state_inactive", |
||
| 87 | default=u"Inactive" |
||
| 88 | ), |
||
| 89 | "contentFilter": {"is_active": False}, |
||
| 90 | "columns": self.columns.keys(), |
||
| 91 | }, { |
||
| 92 | "id": "all", |
||
| 93 | "title": _( |
||
| 94 | u"listing_batchlabels_state_all", |
||
| 95 | default=u"All" |
||
| 96 | ), |
||
| 97 | "contentFilter": {}, |
||
| 98 | "columns": self.columns.keys(), |
||
| 99 | }, |
||
| 105 |