| Conditions | 1 |
| Total Lines | 59 |
| Code Lines | 55 |
| 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 -*- |
||
| 37 | def __init__(self, context, request): |
||
| 38 | super(ContainersView, self).__init__(context, request) |
||
| 39 | self.catalog = 'bika_setup_catalog' |
||
| 40 | self.contentFilter = {'portal_type': 'Container', |
||
| 41 | 'sort_on': 'sortable_title'} |
||
| 42 | self.context_actions = {_('Add'): |
||
| 43 | {'url': 'createObject?type_name=Container', |
||
| 44 | 'permission': AddContainer, |
||
| 45 | 'icon': '++resource++bika.lims.images/add.png'}} |
||
| 46 | self.title = self.context.translate(_("Containers")) |
||
| 47 | self.icon = self.portal_url + "/++resource++bika.lims.images/container_big.png" |
||
| 48 | self.description = "" |
||
| 49 | |||
| 50 | self.show_select_row = False |
||
| 51 | self.show_select_column = True |
||
| 52 | self.pagesize = 25 |
||
| 53 | |||
| 54 | self.columns = { |
||
| 55 | 'Title': {'title': _('Container'), |
||
| 56 | 'index':'sortable_title'}, |
||
| 57 | 'Description': {'title': _('Description'), |
||
| 58 | 'index': 'description', |
||
| 59 | 'toggle': True}, |
||
| 60 | 'ContainerType': {'title': _('Container Type'), |
||
| 61 | 'toggle': True}, |
||
| 62 | 'Capacity': {'title': _('Capacity'), |
||
| 63 | 'toggle': True}, |
||
| 64 | 'Pre-preserved': {'title': _('Pre-preserved'), |
||
| 65 | 'toggle': True}, |
||
| 66 | } |
||
| 67 | |||
| 68 | self.review_states = [ # leave these titles and ids alone |
||
| 69 | {'id':'default', |
||
| 70 | 'contentFilter': {'is_active': True}, |
||
| 71 | 'title': _('Active'), |
||
| 72 | 'transitions': [{'id':'deactivate'}, ], |
||
| 73 | 'columns': ['Title', |
||
| 74 | 'Description', |
||
| 75 | 'ContainerType', |
||
| 76 | 'Capacity', |
||
| 77 | 'Pre-preserved']}, |
||
| 78 | {'id':'inactive', |
||
| 79 | 'title': _('Inactive'), |
||
| 80 | 'contentFilter': {'is_active': False}, |
||
| 81 | 'transitions': [{'id':'activate'}, ], |
||
| 82 | 'columns': ['Title', |
||
| 83 | 'Description', |
||
| 84 | 'ContainerType', |
||
| 85 | 'Capacity', |
||
| 86 | 'Pre-preserved']}, |
||
| 87 | {'id':'all', |
||
| 88 | 'title': _('All'), |
||
| 89 | 'contentFilter':{}, |
||
| 90 | 'transitions': [], |
||
| 91 | 'columns': ['Title', |
||
| 92 | 'Description', |
||
| 93 | 'ContainerType', |
||
| 94 | 'Capacity', |
||
| 95 | 'Pre-preserved']}, |
||
| 96 | ] |
||
| 132 |