Conditions | 1 |
Total Lines | 69 |
Code Lines | 50 |
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 -*- |
||
34 | def __init__(self, context, request): |
||
35 | super(SampleConditionsView, self).__init__(context, request) |
||
36 | |||
37 | self.catalog = SETUP_CATALOG |
||
38 | self.show_select_column = True |
||
39 | |||
40 | self.contentFilter = { |
||
41 | "portal_type": "SampleCondition", |
||
42 | "sort_on": "sortable_title", |
||
43 | "sort_order": "ascending", |
||
44 | } |
||
45 | |||
46 | self.context_actions = { |
||
47 | _(u"listing_sampleconditions_action_add", default=u"Add"): { |
||
48 | "url": "createObject?type_name=SampleCondition", |
||
49 | "permission": AddSampleCondition, |
||
50 | "icon": "++resource++bika.lims.images/add.png" |
||
51 | } |
||
52 | } |
||
53 | |||
54 | self.title = translate(_( |
||
55 | u"listing_sampleconditions_title", |
||
56 | default=u"Sample Conditions") |
||
57 | ) |
||
58 | self.icon = api.get_icon("SampleConditions", html_tag=False) |
||
59 | |||
60 | self.columns = collections.OrderedDict(( |
||
61 | ("Title", { |
||
62 | "title": _( |
||
63 | u"listing_sampleconditions_column_title", |
||
64 | default=u"Sample Condition" |
||
65 | ), |
||
66 | "index": "sortable_title"}), |
||
67 | ("Description", { |
||
68 | "title": _( |
||
69 | u"listing_sampleconditions_column_description", |
||
70 | default=u"Description" |
||
71 | ), |
||
72 | "index": "description", |
||
73 | "toggle": True}), |
||
74 | )) |
||
75 | |||
76 | self.review_states = [ |
||
77 | { |
||
78 | "id": "default", |
||
79 | "title": _( |
||
80 | u"listing_sampleconditions_state_active", |
||
81 | default=u"Active" |
||
82 | ), |
||
83 | "contentFilter": {"is_active": True}, |
||
84 | "transitions": [{"id": "deactivate"}, ], |
||
85 | "columns": self.columns.keys(), |
||
86 | }, { |
||
87 | "id": "inactive", |
||
88 | "title": _( |
||
89 | u"listing_sampleconditions_state_inactive", |
||
90 | default=u"Inactive" |
||
91 | ), |
||
92 | "contentFilter": {'is_active': False}, |
||
93 | "transitions": [{"id": "activate"}, ], |
||
94 | "columns": self.columns.keys(), |
||
95 | }, { |
||
96 | "id": "all", |
||
97 | "title": _( |
||
98 | u"listing_sampleconditions_state_all", |
||
99 | default=u"All" |
||
100 | ), |
||
101 | "contentFilter": {}, |
||
102 | "columns": self.columns.keys(), |
||
103 | }, |
||
116 |