| Conditions | 1 |
| Total Lines | 75 |
| Code Lines | 67 |
| 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 -*- |
||
| 21 | def __init__(self, context, request): |
||
| 22 | super(BatchFolderContentsView, self).__init__(context, request) |
||
| 23 | self.catalog = 'bika_catalog' |
||
| 24 | self.contentFilter = { |
||
| 25 | 'portal_type': 'Batch', |
||
| 26 | 'sort_on': 'created', |
||
| 27 | 'sort_order': 'reverse', |
||
| 28 | 'cancellation_state': 'active' |
||
| 29 | } |
||
| 30 | self.context_actions = {} |
||
| 31 | self.icon = self.portal_url + "/++resource++bika.lims.images/batch_big.png" |
||
| 32 | self.title = self.context.translate(_("Batches")) |
||
| 33 | self.description = "" |
||
| 34 | |||
| 35 | self.show_select_row = False |
||
| 36 | self.show_select_all_checkbox = False |
||
| 37 | self.show_select_column = True |
||
| 38 | self.pagesize = 25 |
||
| 39 | |||
| 40 | self.columns = { |
||
| 41 | 'Title': {'title': _('Title'), |
||
| 42 | 'index': 'title'}, |
||
| 43 | 'BatchID': {'title': _('Batch ID'), |
||
| 44 | 'index': 'getId'}, |
||
| 45 | 'Description': {'title': _('Description'), 'sortable': False}, |
||
| 46 | 'BatchDate': {'title': _('Date')}, |
||
| 47 | 'Client': {'title': _('Client'), |
||
| 48 | 'index': 'getClientTitle'}, |
||
| 49 | 'state_title': {'title': _('State'), 'sortable': False}, |
||
| 50 | 'created': {'title': _('Created'), }, |
||
| 51 | } |
||
| 52 | |||
| 53 | self.review_states = [ # leave these titles and ids alone |
||
| 54 | {'id': 'default', |
||
| 55 | 'contentFilter': {'review_state': 'open'}, |
||
| 56 | 'title': _('Open'), |
||
| 57 | 'transitions': [{'id': 'close'}, {'id': 'cancel'}], |
||
| 58 | 'columns': ['Title', |
||
| 59 | 'BatchID', |
||
| 60 | 'BatchDate', |
||
| 61 | 'Client', |
||
| 62 | 'Description', |
||
| 63 | 'state_title', ] |
||
| 64 | }, |
||
| 65 | {'id': 'closed', |
||
| 66 | 'contentFilter': {'review_state': 'closed'}, |
||
| 67 | 'title': _('Closed'), |
||
| 68 | 'transitions': [{'id': 'open'}], |
||
| 69 | 'columns': ['Title', |
||
| 70 | 'BatchID', |
||
| 71 | 'BatchDate', |
||
| 72 | 'Client', |
||
| 73 | 'Description', |
||
| 74 | 'state_title', ] |
||
| 75 | }, |
||
| 76 | {'id': 'cancelled', |
||
| 77 | 'title': _('Cancelled'), |
||
| 78 | 'transitions': [{'id': 'reinstate'}], |
||
| 79 | 'contentFilter': {'cancellation_state': 'cancelled'}, |
||
| 80 | 'columns': ['Title', |
||
| 81 | 'BatchID', |
||
| 82 | 'BatchDate', |
||
| 83 | 'Client', |
||
| 84 | 'Description', |
||
| 85 | 'state_title', ] |
||
| 86 | }, |
||
| 87 | {'id': 'all', |
||
| 88 | 'title': _('All'), |
||
| 89 | 'transitions': [], |
||
| 90 | 'columns': ['Title', |
||
| 91 | 'BatchID', |
||
| 92 | 'BatchDate', |
||
| 93 | 'Client', |
||
| 94 | 'Description', |
||
| 95 | 'state_title', ] |
||
| 96 | }, |
||
| 189 |