| Conditions | 1 |
| Total Lines | 78 |
| Code Lines | 64 |
| 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 -*- |
||
| 44 | def __init__(self, context, request): |
||
| 45 | super(PatientsView, self).__init__(context, request) |
||
| 46 | self.title = self.context.translate(_("Patients")) |
||
| 47 | self.icon = get_resource_url("patient_big.png") |
||
| 48 | self.form_id = "list_health_patients" |
||
| 49 | self.show_select_row = False |
||
| 50 | self.show_select_column = True |
||
| 51 | self.show_select_all_checkboxes = False |
||
| 52 | request.set("disable_border", 1) |
||
| 53 | |||
| 54 | self.sort_on = "created" |
||
| 55 | self.catalog = CATALOG_PATIENTS |
||
| 56 | self.contentFilter = {'portal_type': 'Patient', |
||
| 57 | 'sort_on': 'created', |
||
| 58 | 'sort_order': 'descending'} |
||
| 59 | |||
| 60 | self.columns = collections.OrderedDict(( |
||
| 61 | ("Title", { |
||
| 62 | "title": _("Patient"), |
||
| 63 | "index": "getFullname", |
||
| 64 | "replace_url": "absolute_url"}), |
||
| 65 | |||
| 66 | ('getPatientID', { |
||
| 67 | 'title': _('Patient ID'), |
||
| 68 | 'index': 'getPatientID', |
||
| 69 | 'replace_url': 'getURL'}), |
||
| 70 | |||
| 71 | ('getClientPatientID', { |
||
| 72 | 'title': _('Client PID'), |
||
| 73 | 'replace_url': 'getURL', |
||
| 74 | 'sortable': False}), |
||
| 75 | |||
| 76 | ('getGender', { |
||
| 77 | 'title': _('Gender'), |
||
| 78 | 'toggle': True, |
||
| 79 | 'sortable': False}), |
||
| 80 | |||
| 81 | ('getAgeSplittedStr', { |
||
| 82 | 'title': _('Age'), |
||
| 83 | 'toggle': True, |
||
| 84 | 'sortable': False}), |
||
| 85 | |||
| 86 | ('getBirthDate', { |
||
| 87 | 'title': _('BirthDate'), |
||
| 88 | 'toggle': True, |
||
| 89 | 'sortable': False}), |
||
| 90 | |||
| 91 | ('getPrimaryReferrerTitle', { |
||
| 92 | 'title': _('Primary Referrer'), |
||
| 93 | 'replace_url': 'getPrimaryReferrerURL', |
||
| 94 | 'toggle': True, |
||
| 95 | 'sortable': False}), |
||
| 96 | |||
| 97 | ('getPatientIdentifiersStr', { |
||
| 98 | 'title': _('Additional IDs'), |
||
| 99 | 'attr': 'getPatientIdentifiersStr', |
||
| 100 | 'toggle': False, |
||
| 101 | 'sortable': False}), |
||
| 102 | )) |
||
| 103 | |||
| 104 | self.review_states = [ |
||
| 105 | { |
||
| 106 | "id": "default", |
||
| 107 | "title": _("Active"), |
||
| 108 | "contentFilter": {"is_active": True}, |
||
| 109 | "transitions": [], |
||
| 110 | "columns": self.columns.keys(), |
||
| 111 | }, { |
||
| 112 | "id": "inactive", |
||
| 113 | "title": _("Inactive"), |
||
| 114 | "contentFilter": {'is_active': False}, |
||
| 115 | "transitions": [], |
||
| 116 | "columns": self.columns.keys(), |
||
| 117 | }, { |
||
| 118 | "id": "all", |
||
| 119 | "title": _("All"), |
||
| 120 | "contentFilter": {}, |
||
| 121 | "columns": self.columns.keys(), |
||
| 122 | }, |
||
| 175 |