| Conditions | 1 |
| Total Lines | 52 |
| Code Lines | 38 |
| Lines | 52 |
| 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 -*- |
||
| 35 | def __init__(self, context, request): |
||
| 36 | super(InstrumentLocationsView, self).__init__(context, request) |
||
| 37 | |||
| 38 | self.catalog = SETUP_CATALOG |
||
| 39 | |||
| 40 | self.contentFilter = { |
||
| 41 | "portal_type": "InstrumentLocation", |
||
| 42 | "sort_on": "sortable_title", |
||
| 43 | } |
||
| 44 | |||
| 45 | self.context_actions = { |
||
| 46 | _("Add"): { |
||
| 47 | "url": "++add++InstrumentLocation", |
||
| 48 | "permission": AddInstrumentLocation, |
||
| 49 | "icon": "++resource++bika.lims.images/add.png", |
||
| 50 | }} |
||
| 51 | |||
| 52 | t = self.context.translate |
||
| 53 | self.title = t(_("Instrument Locations")) |
||
| 54 | self.description = t(_( |
||
| 55 | "The place where the instrument is located in the laboratory")) |
||
| 56 | |||
| 57 | self.show_select_column = True |
||
| 58 | self.pagesize = 25 |
||
| 59 | |||
| 60 | self.columns = collections.OrderedDict(( |
||
| 61 | ("Title", { |
||
| 62 | "title": _("Location"), |
||
| 63 | "index": "sortable_title"}), |
||
| 64 | ("Description", { |
||
| 65 | "title": _("Description"), |
||
| 66 | "index": "Description", |
||
| 67 | "toggle": True, |
||
| 68 | }), |
||
| 69 | )) |
||
| 70 | |||
| 71 | self.review_states = [ |
||
| 72 | { |
||
| 73 | "id": "default", |
||
| 74 | "title": _("Active"), |
||
| 75 | "contentFilter": {"is_active": True}, |
||
| 76 | "columns": self.columns.keys(), |
||
| 77 | }, { |
||
| 78 | "id": "inactive", |
||
| 79 | "title": _("Inactive"), |
||
| 80 | "contentFilter": {'is_active': False}, |
||
| 81 | "columns": self.columns.keys(), |
||
| 82 | }, { |
||
| 83 | "id": "all", |
||
| 84 | "title": _("All"), |
||
| 85 | "contentFilter": {}, |
||
| 86 | "columns": self.columns.keys(), |
||
| 87 | }, |
||
| 104 |