Conditions | 5 |
Total Lines | 56 |
Lines | 56 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
15 | def __init__(self, |
||
16 | field_name=None, |
||
17 | any_permission=None, |
||
18 | change_permission=None, |
||
19 | delete_permission=None): |
||
20 | """ |
||
21 | Constructor |
||
22 | |||
23 | Parameters |
||
24 | ---------- |
||
25 | field_name : string |
||
26 | A field name of object which store the collaborators as django |
||
27 | relational fields for django user model. |
||
28 | You can specify the related object with '__' like django queryset |
||
29 | filter. |
||
30 | Default value will be taken from |
||
31 | ``PERMISSION_DEFAULT_COLLABORATORS_PERMISSION_LOGIC_FIELD_NAME`` in |
||
32 | settings. |
||
33 | any_permission : boolean |
||
34 | True for give any permission of the specified object to the |
||
35 | collaborators. |
||
36 | Default value will be taken from |
||
37 | ``PERMISSION_DEFAULT_COLLABORATORS_PERMISSION_LOGIC_ANY_PERMISSION`` |
||
38 | in settings. |
||
39 | change_permission : boolean |
||
40 | True for give change permission of the specified object to the |
||
41 | collaborators. |
||
42 | It will be ignored if :attr:`any_permission` is True. |
||
43 | Default value will be taken from |
||
44 | ``PERMISSION_DEFAULT_COLLABORATORS_PERMISSION_LOGIC_CHANGE_PERMISSION`` |
||
45 | in settings. |
||
46 | delete_permission : boolean |
||
47 | True for give delete permission of the specified object to the |
||
48 | collaborators. |
||
49 | It will be ignored if :attr:`any_permission` is True. |
||
50 | Default value will be taken from |
||
51 | ``PERMISSION_DEFAULT_COLLABORATORS_PERMISSION_LOGIC_DELETE_PERMISSION`` |
||
52 | in settings. |
||
53 | """ |
||
54 | self.field_name = field_name |
||
55 | self.any_permission = any_permission |
||
56 | self.change_permission = change_permission |
||
57 | self.delete_permission = delete_permission |
||
58 | |||
59 | if self.field_name is None: |
||
60 | self.field_name = \ |
||
61 | settings.PERMISSION_DEFAULT_CPL_FIELD_NAME |
||
62 | if self.any_permission is None: |
||
63 | self.any_permission = \ |
||
64 | settings.PERMISSION_DEFAULT_CPL_ANY_PERMISSION |
||
65 | if self.change_permission is None: |
||
66 | self.change_permission = \ |
||
67 | settings.PERMISSION_DEFAULT_CPL_CHANGE_PERMISSION |
||
68 | if self.delete_permission is None: |
||
69 | self.delete_permission = \ |
||
70 | settings.PERMISSION_DEFAULT_CPL_DELETE_PERMISSION |
||
71 | |||
138 |