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