Conditions | 1 |
Total Lines | 68 |
Code Lines | 57 |
Lines | 68 |
Ratio | 100 % |
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 -*- |
||
45 | View Code Duplication | def __init__(self, context, request): |
|
|
|||
46 | super(AuditLogView, self).__init__(context, request) |
||
47 | |||
48 | self.catalog = AUDITLOG_CATALOG |
||
49 | |||
50 | self.contentFilter = { |
||
51 | "path": "/", |
||
52 | "sort_on": "snapshot_created", |
||
53 | "sort_order": "descending", |
||
54 | } |
||
55 | |||
56 | self.context_actions = {} |
||
57 | |||
58 | self.title = self.context.translate(_("Audit Log")) |
||
59 | self.icon = "{}/{}".format( |
||
60 | self.portal_url, |
||
61 | "/++resource++bika.lims.images/auditlog_big.png" |
||
62 | ) |
||
63 | |||
64 | self.show_select_column = False |
||
65 | self.pagesize = 25 |
||
66 | |||
67 | self.columns = collections.OrderedDict(( |
||
68 | ("title", { |
||
69 | "title": _("Title"), |
||
70 | "index": "title"}), |
||
71 | ("version", { |
||
72 | "title": _("Version"), |
||
73 | "index": "snapshot_version", |
||
74 | "sortable": True}), |
||
75 | ("modified", { |
||
76 | "title": _("Date Modified"), |
||
77 | "index": "modified", |
||
78 | "sortable": True}), |
||
79 | ("actor", { |
||
80 | "title": _("Actor"), |
||
81 | "index": "actor", |
||
82 | "sortable": True}), |
||
83 | ("fullname", { |
||
84 | "title": _("Fullname"), |
||
85 | "index": "fullname", |
||
86 | "sortable": True}), |
||
87 | ("roles", { |
||
88 | "title": _("Roles"), |
||
89 | "sortable": False, |
||
90 | "toggle": False}), |
||
91 | ("remote_address", { |
||
92 | "title": _("Remote IP"), |
||
93 | "sortable": True}), |
||
94 | ("action", { |
||
95 | "title": _("Action"), |
||
96 | "index": "action", |
||
97 | "sortable": True}), |
||
98 | ("review_state", { |
||
99 | "title": _("Workflow State"), |
||
100 | "index": "review_state", |
||
101 | "sortable": True}), |
||
102 | ("diff", { |
||
103 | "title": _("Changes"), |
||
104 | "sortable": False}), |
||
105 | )) |
||
106 | |||
107 | self.review_states = [ |
||
108 | { |
||
109 | "id": "default", |
||
110 | "title": _("Active"), |
||
111 | "contentFilter": {}, |
||
112 | "columns": self.columns.keys(), |
||
113 | } |
||
209 |