| Conditions | 1 | 
| Total Lines | 62 | 
| Code Lines | 48 | 
| 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(SampleContainersView, self).__init__(context, request)  | 
            ||
| 36 | |||
| 37 | self.catalog = SETUP_CATALOG  | 
            ||
| 38 | |||
| 39 |         self.contentFilter = { | 
            ||
| 40 | "portal_type": "SampleContainer",  | 
            ||
| 41 | "sort_on": "sortable_title",  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 |         self.context_actions = { | 
            ||
| 45 |             _("Add"): { | 
            ||
| 46 | "url": "++add++SampleContainer",  | 
            ||
| 47 | "icon": "++resource++bika.lims.images/add.png",  | 
            ||
| 48 | }}  | 
            ||
| 49 | |||
| 50 | t = self.context.translate  | 
            ||
| 51 |         self.title = t(_("Sample Containers")) | 
            ||
| 52 |         self.description = t(_("")) | 
            ||
| 53 | |||
| 54 | self.show_select_column = True  | 
            ||
| 55 | self.pagesize = 25  | 
            ||
| 56 | |||
| 57 | self.columns = collections.OrderedDict((  | 
            ||
| 58 |             ("title", { | 
            ||
| 59 |                 "title": _("Container"), | 
            ||
| 60 | "index": "sortable_title"}),  | 
            ||
| 61 |             ("description", { | 
            ||
| 62 |                 "title": _("Description"), | 
            ||
| 63 | "index": "Description",  | 
            ||
| 64 | "toggle": True,  | 
            ||
| 65 | }),  | 
            ||
| 66 |             ("containertype", { | 
            ||
| 67 |                 "title": _("Container Type"), | 
            ||
| 68 | "toggle": True}),  | 
            ||
| 69 |             ("capacity", { | 
            ||
| 70 |                 "title": _("Capacity"), | 
            ||
| 71 | "toggle": True}),  | 
            ||
| 72 |             ("pre_preserved", { | 
            ||
| 73 |                 "title": _("Pre-preserved"), | 
            ||
| 74 | "toggle": True}),  | 
            ||
| 75 |             ("security_seal_intact", { | 
            ||
| 76 |                 "title": _("Security seal intact"), | 
            ||
| 77 | "toggle": True}),  | 
            ||
| 78 | ))  | 
            ||
| 79 | |||
| 80 | self.review_states = [  | 
            ||
| 81 |             { | 
            ||
| 82 | "id": "default",  | 
            ||
| 83 |                 "title": _("Active"), | 
            ||
| 84 |                 "contentFilter": {"is_active": True}, | 
            ||
| 85 | "columns": self.columns.keys(),  | 
            ||
| 86 |             }, { | 
            ||
| 87 | "id": "inactive",  | 
            ||
| 88 |                 "title": _("Inactive"), | 
            ||
| 89 |                 "contentFilter": {'is_active': False}, | 
            ||
| 90 | "columns": self.columns.keys(),  | 
            ||
| 91 |             }, { | 
            ||
| 92 | "id": "all",  | 
            ||
| 93 |                 "title": _("All"), | 
            ||
| 94 |                 "contentFilter": {}, | 
            ||
| 95 | "columns": self.columns.keys(),  | 
            ||
| 96 | },  | 
            ||
| 134 |