| Conditions | 4 |
| Total Lines | 74 |
| 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 -*- |
||
| 30 | def __init__(self, context, request): |
||
| 31 | super(AnalysisRequestAnalysesView, self).__init__(context, request) |
||
| 32 | |||
| 33 | self.catalog = "bika_setup_catalog" |
||
| 34 | self.contentFilter = { |
||
| 35 | "portal_type": "AnalysisService", |
||
| 36 | "sort_on": "sortable_title", |
||
| 37 | "sort_order": "ascending", |
||
| 38 | "inactive_state": "active" |
||
| 39 | } |
||
| 40 | self.context_actions = {} |
||
| 41 | self.icon = "{}/{}".format( |
||
| 42 | self.portal_url, |
||
| 43 | "++resource++bika.lims.images/analysisservice_big.png" |
||
| 44 | ) |
||
| 45 | self.show_column_toggles = False |
||
| 46 | self.show_select_column = True |
||
| 47 | self.show_select_all_checkbox = False |
||
| 48 | self.pagesize = 999999 |
||
| 49 | self.show_search = True |
||
| 50 | self.fetch_transitions_on_select = False |
||
| 51 | |||
| 52 | self.categories = [] |
||
| 53 | self.selected = [] |
||
| 54 | self.do_cats = self.context.bika_setup.getCategoriseAnalysisServices() |
||
| 55 | if self.do_cats: |
||
| 56 | self.show_categories = True |
||
| 57 | self.expand_all_categories = False |
||
| 58 | |||
| 59 | self.columns = collections.OrderedDict(( |
||
| 60 | ("Title", { |
||
| 61 | "title": _("Service"), |
||
| 62 | "index": "sortable_title", |
||
| 63 | "sortable": False}), |
||
| 64 | ("Unit", { |
||
| 65 | "title": _("Unit"), |
||
| 66 | "sortable": False}), |
||
| 67 | ("Hidden", { |
||
| 68 | "title": _("Hidden"), |
||
| 69 | "sortable": False, |
||
| 70 | "type": "boolean"}), |
||
| 71 | ("Price", { |
||
| 72 | "title": _("Price"), |
||
| 73 | "sortable": False}), |
||
| 74 | ("warn_min", { |
||
| 75 | "title": _("Min warn")}), |
||
| 76 | ("min", { |
||
| 77 | "title": _("Min")}), |
||
| 78 | ("warn_max", { |
||
| 79 | "title": _("Max warn")}), |
||
| 80 | ("max", { |
||
| 81 | "title": _("Max")}), |
||
| 82 | )) |
||
| 83 | |||
| 84 | columns = ["Title", "Unit", "Hidden", ] |
||
| 85 | if self.show_prices(): |
||
| 86 | columns.append("Price") |
||
| 87 | if self.show_ar_specs(): |
||
| 88 | columns.append("warn_min") |
||
| 89 | columns.append("min") |
||
| 90 | columns.append("warn_max") |
||
| 91 | columns.append("max") |
||
| 92 | |||
| 93 | self.review_states = [ |
||
| 94 | { |
||
| 95 | "id": "default", |
||
| 96 | "title": _("All"), |
||
| 97 | "contentFilter": {"inactive_state": "active"}, |
||
| 98 | "columns": columns, |
||
| 99 | "transitions": [{"id": "disallow-all-possible-transitions"}], |
||
| 100 | "custom_transitions": [ |
||
| 101 | { |
||
| 102 | "id": "save_analyses_button", |
||
| 103 | "title": _("Save") |
||
| 104 | } |
||
| 247 |