Conditions | 1 |
Total Lines | 55 |
Code Lines | 43 |
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(PatientMultifileView, self).__init__(context, request) |
||
36 | |||
37 | self.catalog = "bika_setup_catalog" |
||
38 | self.contentFilter = { |
||
39 | "portal_type": "Multifile", |
||
40 | "path": { |
||
41 | "query": api.get_path(context), |
||
42 | "depth": 1 # searching just inside the specified folder |
||
43 | }, |
||
44 | "sort_on": "created", |
||
45 | "sort_order": "descending", |
||
46 | } |
||
47 | |||
48 | self.form_id = "patientfiles" |
||
49 | self.title = self.context.translate(_("Patient Files")) |
||
50 | self.icon = "{}/{}".format( |
||
51 | self.portal_url, |
||
52 | "++resource++bika.lims.images/instrumentcertification_big.png" |
||
53 | ) |
||
54 | self.context_actions = { |
||
55 | _("Add"): { |
||
56 | "url": "createObject?type_name=Multifile", |
||
57 | "icon": "++resource++bika.lims.images/add.png" |
||
58 | } |
||
59 | } |
||
60 | |||
61 | self.allow_edit = False |
||
62 | self.show_select_column = False |
||
63 | self.show_workflow_action_buttons = True |
||
64 | self.pagesize = 30 |
||
65 | |||
66 | self.columns = { |
||
67 | "DocumentID": {"title": _("Document ID"), |
||
68 | "index": "sortable_title"}, |
||
69 | "DocumentVersion": {"title": _("Document Version"), |
||
70 | "index": "sortable_title"}, |
||
71 | "DocumentLocation": {"title": _("Document Location"), |
||
72 | "index": "sortable_title"}, |
||
73 | "DocumentType": {"title": _("Document Type"), |
||
74 | "index": "sortable_title"}, |
||
75 | "FileDownload": {"title": _("File")} |
||
76 | } |
||
77 | |||
78 | self.review_states = [ |
||
79 | { |
||
80 | "id": "default", |
||
81 | "title": _("All"), |
||
82 | "contentFilter": {}, |
||
83 | "columns": [ |
||
84 | "DocumentID", |
||
85 | "DocumentVersion", |
||
86 | "DocumentLocation", |
||
87 | "DocumentType", |
||
88 | "FileDownload" |
||
89 | ] |
||
124 |