| Conditions | 1 |
| Total Lines | 57 |
| Code Lines | 50 |
| Lines | 57 |
| 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 -*- |
||
| 39 | View Code Duplication | def __init__(self, context, request): |
|
|
|
|||
| 40 | super(ClientContactsView, self).__init__(context, request) |
||
| 41 | self.catalog = CONTACT_CATALOG |
||
| 42 | self.contentFilter = { |
||
| 43 | "portal_type": "Contact", |
||
| 44 | "sort_on": "sortable_title", |
||
| 45 | "path": { |
||
| 46 | "query": "/".join(context.getPhysicalPath()), |
||
| 47 | "level": 0 |
||
| 48 | } |
||
| 49 | } |
||
| 50 | self.context_actions = { |
||
| 51 | _("Add"): |
||
| 52 | {"url": "++add++Contact", |
||
| 53 | "permission": "Add portal content", |
||
| 54 | "icon": "++resource++bika.lims.images/add.png"}} |
||
| 55 | |||
| 56 | self.show_select_row = False |
||
| 57 | self.show_select_column = True |
||
| 58 | self.pagesize = 50 |
||
| 59 | self.form_id = "contacts" |
||
| 60 | |||
| 61 | self.icon = self.portal_url + \ |
||
| 62 | "/++resource++bika.lims.images/client_contact_big.png" |
||
| 63 | self.title = self.context.translate(_("Contacts")) |
||
| 64 | self.description = "" |
||
| 65 | |||
| 66 | self.columns = OrderedDict(( |
||
| 67 | ("getFullname", { |
||
| 68 | "title": _("Full Name"), |
||
| 69 | "index": "getFullname", |
||
| 70 | "sortable": True, }), |
||
| 71 | ("Username", { |
||
| 72 | "title": _("User Name"), }), |
||
| 73 | ("getEmailAddress", { |
||
| 74 | "title": _("Email Address"), }), |
||
| 75 | ("getBusinessPhone", { |
||
| 76 | "title": _("Business Phone"), }), |
||
| 77 | ("getMobilePhone", { |
||
| 78 | "title": _("MobilePhone"), }), |
||
| 79 | )) |
||
| 80 | |||
| 81 | self.review_states = [ |
||
| 82 | {"id": "default", |
||
| 83 | "title": _("Active"), |
||
| 84 | "contentFilter": {"is_active": True}, |
||
| 85 | "transitions": [{"id": "deactivate"}, ], |
||
| 86 | "columns": self.columns.keys()}, |
||
| 87 | {"id": "inactive", |
||
| 88 | "title": _("Inactive"), |
||
| 89 | "contentFilter": {"is_active": False}, |
||
| 90 | "transitions": [{"id": "activate"}, ], |
||
| 91 | "columns": self.columns.keys()}, |
||
| 92 | {"id": "all", |
||
| 93 | "title": _("All"), |
||
| 94 | "contentFilter": {}, |
||
| 95 | "columns": self.columns.keys()}, |
||
| 96 | ] |
||
| 123 |