| Conditions | 1 |
| Total Lines | 60 |
| Code Lines | 47 |
| 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 -*- |
||
| 15 | def __init__(self, context, request): |
||
| 16 | super(SampleContainersView, self).__init__(context, request) |
||
| 17 | |||
| 18 | self.contentFilter = { |
||
| 19 | "portal_type": "SampleContainer", |
||
| 20 | "sort_on": "sortable_title", |
||
| 21 | } |
||
| 22 | |||
| 23 | self.context_actions = { |
||
| 24 | _("Add"): { |
||
| 25 | "url": "++add++SampleContainer", |
||
| 26 | "icon": "++resource++bika.lims.images/add.png", |
||
| 27 | }} |
||
| 28 | |||
| 29 | t = self.context.translate |
||
| 30 | self.title = t(_("Sample Containers")) |
||
| 31 | self.description = t(_("")) |
||
| 32 | |||
| 33 | self.show_select_column = True |
||
| 34 | self.pagesize = 25 |
||
| 35 | |||
| 36 | self.columns = collections.OrderedDict(( |
||
| 37 | ("title", { |
||
| 38 | "title": _("Container"), |
||
| 39 | "index": "sortable_title"}), |
||
| 40 | ("description", { |
||
| 41 | "title": _("Description"), |
||
| 42 | "index": "Description", |
||
| 43 | "toggle": True, |
||
| 44 | }), |
||
| 45 | ("containertype", { |
||
| 46 | "title": _("Container Type"), |
||
| 47 | "toggle": True}), |
||
| 48 | ("capacity", { |
||
| 49 | "title": _("Capacity"), |
||
| 50 | "toggle": True}), |
||
| 51 | ("pre_preserved", { |
||
| 52 | "title": _("Pre-preserved"), |
||
| 53 | "toggle": True}), |
||
| 54 | ("security_seal_intact", { |
||
| 55 | "title": _("Security seal intact"), |
||
| 56 | "toggle": True}), |
||
| 57 | )) |
||
| 58 | |||
| 59 | self.review_states = [ |
||
| 60 | { |
||
| 61 | "id": "default", |
||
| 62 | "title": _("Active"), |
||
| 63 | "contentFilter": {"is_active": True}, |
||
| 64 | "columns": self.columns.keys(), |
||
| 65 | }, { |
||
| 66 | "id": "inactive", |
||
| 67 | "title": _("Inactive"), |
||
| 68 | "contentFilter": {'is_active': False}, |
||
| 69 | "columns": self.columns.keys(), |
||
| 70 | }, { |
||
| 71 | "id": "all", |
||
| 72 | "title": _("All"), |
||
| 73 | "contentFilter": {}, |
||
| 74 | "columns": self.columns.keys(), |
||
| 75 | }, |
||
| 113 |