| Conditions | 1 |
| Total Lines | 53 |
| Code Lines | 40 |
| Lines | 53 |
| 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 -*- |
||
| 30 | View Code Duplication | def __init__(self, context, request): |
|
|
|
|||
| 31 | super(ReferenceDefinitionsView, self).__init__(context, request) |
||
| 32 | |||
| 33 | self.catalog = "bika_setup_catalog" |
||
| 34 | |||
| 35 | self.contentFilter = { |
||
| 36 | "portal_type": "ReferenceDefinition", |
||
| 37 | "sort_on": "sortable_title", |
||
| 38 | "sort_order": "ascending" |
||
| 39 | |||
| 40 | } |
||
| 41 | |||
| 42 | self.context_actions = { |
||
| 43 | _("Add"): { |
||
| 44 | "url": "createObject?type_name=ReferenceDefinition", |
||
| 45 | "permission": AddReferenceDefinition, |
||
| 46 | "icon": "++resource++bika.lims.images/add.png"}} |
||
| 47 | |||
| 48 | self.title = self.context.translate(_("Reference Definitions")) |
||
| 49 | self.description = "" |
||
| 50 | self.icon = "{}/{}".format( |
||
| 51 | self.portal_url, |
||
| 52 | "++resource++bika.lims.images/referencedefinition_big.png") |
||
| 53 | |||
| 54 | self.show_select_column = True |
||
| 55 | self.pagesize = 25 |
||
| 56 | |||
| 57 | self.columns = collections.OrderedDict(( |
||
| 58 | ("Title", { |
||
| 59 | "title": _("Title"), |
||
| 60 | "index": "sortable_title"}), |
||
| 61 | ("Description", { |
||
| 62 | "title": _("Description"), |
||
| 63 | "index": "description", |
||
| 64 | "toggle": True}), |
||
| 65 | )) |
||
| 66 | |||
| 67 | self.review_states = [ |
||
| 68 | { |
||
| 69 | "id": "default", |
||
| 70 | "title": _("Active"), |
||
| 71 | "contentFilter": {"is_active": True}, |
||
| 72 | "columns": self.columns.keys(), |
||
| 73 | }, { |
||
| 74 | "id": "inactive", |
||
| 75 | "title": _("Inactive"), |
||
| 76 | "contentFilter": {"is_active": False}, |
||
| 77 | "columns": self.columns.keys(), |
||
| 78 | }, { |
||
| 79 | "id": "all", |
||
| 80 | "title": _("All"), |
||
| 81 | "contentFilter": {}, |
||
| 82 | "columns": self.columns.keys(), |
||
| 83 | }, |
||
| 141 |