| Conditions | 4 |
| Total Lines | 61 |
| Code Lines | 44 |
| 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 -*- |
||
| 25 | def __init__(self, context, request): |
||
| 26 | super(ServicesView, self).__init__(context, request) |
||
| 27 | |||
| 28 | self.catalog = "bika_setup_catalog" |
||
| 29 | self.contentFilter = { |
||
| 30 | "portal_type": "AnalysisService", |
||
| 31 | "sort_on": "sortable_title", |
||
| 32 | "sort_order": "ascending", |
||
| 33 | } |
||
| 34 | |||
| 35 | if context.getRestrictToMethod(): |
||
| 36 | method_uid = context.getMethodUID() |
||
| 37 | if method_uid: |
||
| 38 | self.contentFilter.update({ |
||
| 39 | "getAvailableMethodUIDs": method_uid |
||
| 40 | }) |
||
| 41 | |||
| 42 | self.context_actions = {} |
||
| 43 | |||
| 44 | # selected services UIDs |
||
| 45 | self.selected_services_uids = self.get_assigned_services_uids() |
||
| 46 | |||
| 47 | self.show_sort_column = False |
||
| 48 | self.show_column_toggles = False |
||
| 49 | self.show_select_column = True |
||
| 50 | self.show_select_all_checkbox = False |
||
| 51 | self.pagesize = 999999 |
||
| 52 | self.allow_edit = True |
||
| 53 | # remove the searchbox |
||
| 54 | self.show_search = False |
||
| 55 | # omit the outer form |
||
| 56 | self.omit_form = True |
||
| 57 | # no need to fetch the allowed transitions on select |
||
| 58 | self.fetch_transitions_on_select = False |
||
| 59 | |||
| 60 | # Categories |
||
| 61 | if self.show_categories_enabled(): |
||
| 62 | self.categories = [] |
||
| 63 | self.show_categories = True |
||
| 64 | self.expand_all_categories = False |
||
| 65 | self.category_index = "getCategoryTitle" |
||
| 66 | |||
| 67 | self.columns = collections.OrderedDict(( |
||
| 68 | ("Title", { |
||
| 69 | "title": _("Service")}), |
||
| 70 | ("Keyword", { |
||
| 71 | "title": _("Keyword"), |
||
| 72 | "index": "getKeyword"}), |
||
| 73 | ("Methods", { |
||
| 74 | "title": _("Methods")}), |
||
| 75 | ("Calculation", { |
||
| 76 | "title": _("Calculation")}), |
||
| 77 | )) |
||
| 78 | |||
| 79 | self.review_states = [ |
||
| 80 | { |
||
| 81 | "id": "default", |
||
| 82 | "title": _("All"), |
||
| 83 | "contentFilter": {"inactive_state": "active"}, |
||
| 84 | "transitions": [{"id": "disallow-all-possible-transitions"}], |
||
| 85 | "columns": self.columns.keys(), |
||
| 86 | } |
||
| 221 |