| Conditions | 1 |
| Total Lines | 77 |
| Code Lines | 54 |
| 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 -*- |
||
| 36 | def __init__(self, context, request): |
||
| 37 | super(ManufacturersView, self).__init__(context, request) |
||
| 38 | |||
| 39 | self.catalog = SETUP_CATALOG |
||
| 40 | |||
| 41 | self.contentFilter = { |
||
| 42 | "portal_type": "Manufacturer", |
||
| 43 | "sort_on": "sortable_title", |
||
| 44 | "path": { |
||
| 45 | "query": api.get_path(self.context), |
||
| 46 | "depth": 1, |
||
| 47 | }, |
||
| 48 | } |
||
| 49 | |||
| 50 | self.context_actions = { |
||
| 51 | _(u"listing_manufacturers_action_add", default=u"Add"): { |
||
| 52 | "url": "++add++Manufacturer", |
||
| 53 | "permission": AddManufacturer, |
||
| 54 | "icon": "senaite_theme/icon/plus" |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | self.title = translate(_( |
||
| 59 | u"listing_manufacturers_title", |
||
| 60 | default=u"Manufacturers") |
||
| 61 | ) |
||
| 62 | self.description = "" |
||
| 63 | self.icon = "{}/{}".format( |
||
| 64 | self.portal_url, |
||
| 65 | "/++resource++bika.lims.images/manufacturer_big.png" |
||
| 66 | ) |
||
| 67 | |||
| 68 | self.show_select_row = False |
||
| 69 | self.show_select_column = True |
||
| 70 | self.show_all = False |
||
| 71 | |||
| 72 | self.columns = collections.OrderedDict(( |
||
| 73 | ("Title", { |
||
| 74 | "title": _( |
||
| 75 | u"listing_manufacturers_column_title", |
||
| 76 | default=u"Title", |
||
| 77 | ), |
||
| 78 | "index": "sortable_title"}), |
||
| 79 | ("Description", { |
||
| 80 | "title": _( |
||
| 81 | u"listing_manufacturers_column_description", |
||
| 82 | default=u"Description" |
||
| 83 | ), |
||
| 84 | "toggle": True, |
||
| 85 | }), |
||
| 86 | )) |
||
| 87 | |||
| 88 | self.review_states = [ |
||
| 89 | { |
||
| 90 | "id": "default", |
||
| 91 | "title": _( |
||
| 92 | u"listing_manufacturers_state_active", |
||
| 93 | default=u"Active", |
||
| 94 | ), |
||
| 95 | "contentFilter": {"is_active": True}, |
||
| 96 | "columns": self.columns.keys(), |
||
| 97 | }, { |
||
| 98 | "id": "inactive", |
||
| 99 | "title": _( |
||
| 100 | u"listing_manufacturers_state_inactive", |
||
| 101 | default=u"Inactive", |
||
| 102 | ), |
||
| 103 | "contentFilter": {'is_active': False}, |
||
| 104 | "columns": self.columns.keys(), |
||
| 105 | }, { |
||
| 106 | "id": "all", |
||
| 107 | "title": _( |
||
| 108 | u"listing_manufacturers_state_all", |
||
| 109 | default=u"All", |
||
| 110 | ), |
||
| 111 | "contentFilter": {}, |
||
| 112 | "columns": self.columns.keys(), |
||
| 113 | }, |
||
| 134 |