Conditions | 1 |
Total Lines | 72 |
Code Lines | 48 |
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 -*- |
||
35 | def __init__(self, context, request): |
||
36 | super(ContactsView, self).__init__(context, request) |
||
37 | |||
38 | self.catalog = CONTACT_CATALOG |
||
39 | |||
40 | self.contentFilter = { |
||
41 | "portal_type": "SupplierContact", |
||
42 | "sort_on": "sortable_title", |
||
43 | "sort_order": "ascending", |
||
44 | "path": { |
||
45 | "query": "/".join(context.getPhysicalPath()), |
||
46 | "level": 0, |
||
47 | } |
||
48 | } |
||
49 | |||
50 | self.context_actions = { |
||
51 | _("listing_suppliercontacts_action_add", default="Add"): { |
||
52 | "url": "createObject?type_name=SupplierContact", |
||
53 | "permission": "Add portal content", |
||
54 | "icon": "senaite_theme/icon/plus" |
||
55 | } |
||
56 | } |
||
57 | |||
58 | self.title = translate(_( |
||
59 | "listing_suppliercontacts_title", |
||
60 | default="Contacts") |
||
61 | ) |
||
62 | self.icon = api.get_icon("Contact", html_tag=False) |
||
63 | self.show_select_column = True |
||
64 | |||
65 | self.columns = collections.OrderedDict(( |
||
66 | ("getFullname", { |
||
67 | "title": _( |
||
68 | u"listing_suppliercontacts_column_fullname", |
||
69 | default=u"FullName" |
||
70 | ) |
||
71 | }), |
||
72 | ("getEmailAddress", { |
||
73 | "title": _( |
||
74 | u"listing_suppliercontacts_column_emailaddress", |
||
75 | default=u"Email Address" |
||
76 | ) |
||
77 | }), |
||
78 | ("getBusinessPhone", { |
||
79 | "title": _( |
||
80 | u"listing_suppliercontacts_column_businessphone", |
||
81 | default=u"Business Phone" |
||
82 | ) |
||
83 | }), |
||
84 | ("getMobilePhone", { |
||
85 | "title": _( |
||
86 | u"listing_suppliercontacts_column_mobilephone", |
||
87 | default=u"Mobile Phone" |
||
88 | ) |
||
89 | }), |
||
90 | ("getFax", { |
||
91 | "title": _( |
||
92 | u"listing_suppliercontacts_column_fax", |
||
93 | default=u"Fax" |
||
94 | ) |
||
95 | }), |
||
96 | )) |
||
97 | |||
98 | self.review_states = [ |
||
99 | { |
||
100 | "id": "default", |
||
101 | "title": _( |
||
102 | u"listing_suppliercontacts_state_all", |
||
103 | default=u"All" |
||
104 | ), |
||
105 | "contentFilter": {}, |
||
106 | "columns": self.columns.keys(), |
||
107 | }, |
||
118 |