| Conditions | 1 |
| Total Lines | 69 |
| Code Lines | 55 |
| Lines | 69 |
| 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 -*- |
||
| 33 | View Code Duplication | def __init__(self, context, request): |
|
|
|
|||
| 34 | super(DepartmentsView, self).__init__(context, request) |
||
| 35 | |||
| 36 | self.catalog = "bika_setup_catalog" |
||
| 37 | |||
| 38 | self.contentFilter = { |
||
| 39 | "portal_type": "Department", |
||
| 40 | "sort_order": "ascending", |
||
| 41 | "sort_on": "sortable_title" |
||
| 42 | } |
||
| 43 | |||
| 44 | self.context_actions = { |
||
| 45 | _("Add"): { |
||
| 46 | "url": "createObject?type_name=Department", |
||
| 47 | "permission": "Add portal content", |
||
| 48 | "icon": "++resource++bika.lims.images/add.png"} |
||
| 49 | } |
||
| 50 | |||
| 51 | self.title = self.context.translate(_("Lab Departments")) |
||
| 52 | self.icon = "{}/{}".format( |
||
| 53 | self.portal_url, |
||
| 54 | "/++resource++bika.lims.images/department_big.png" |
||
| 55 | ) |
||
| 56 | |||
| 57 | self.show_sort_column = False |
||
| 58 | self.show_select_row = False |
||
| 59 | self.show_select_column = True |
||
| 60 | self.pagesize = 25 |
||
| 61 | |||
| 62 | self.columns = collections.OrderedDict(( |
||
| 63 | ("Title", { |
||
| 64 | "title": _("Department"), |
||
| 65 | "index": "sortable_title"}), |
||
| 66 | ("Description", { |
||
| 67 | "title": _("Description"), |
||
| 68 | "index": "Description", |
||
| 69 | "toggle": True}), |
||
| 70 | ("Manager", { |
||
| 71 | "title": _("Manager"), |
||
| 72 | "index": "getManagerName", |
||
| 73 | "toggle": True}), |
||
| 74 | ("ManagerPhone", { |
||
| 75 | "title": _("Manager Phone"), |
||
| 76 | "index": "getManagerPhone", |
||
| 77 | "toggle": True}), |
||
| 78 | ("ManagerEmail", { |
||
| 79 | "title": _("Manager Email"), |
||
| 80 | "index": "getManagerEmail", |
||
| 81 | "toggle": True}), |
||
| 82 | )) |
||
| 83 | |||
| 84 | self.review_states = [ |
||
| 85 | { |
||
| 86 | "id": "default", |
||
| 87 | "title": _("Active"), |
||
| 88 | "contentFilter": {"inactive_state": "active"}, |
||
| 89 | "transitions": [{"id": "deactivate"}, ], |
||
| 90 | "columns": self.columns.keys(), |
||
| 91 | }, { |
||
| 92 | "id": "inactive", |
||
| 93 | "title": _("Dormant"), |
||
| 94 | "contentFilter": {"inactive_state": "inactive"}, |
||
| 95 | "transitions": [{"id": "activate"}, ], |
||
| 96 | "columns": self.columns.keys(), |
||
| 97 | }, { |
||
| 98 | "id": "all", |
||
| 99 | "title": _("All"), |
||
| 100 | "contentFilter": {}, |
||
| 101 | "columns": self.columns.keys(), |
||
| 102 | }, |
||
| 180 |