| Conditions | 5 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 14 | def __init__(self, |
||
| 15 | any_permission=None, |
||
| 16 | add_permission=None, |
||
| 17 | change_permission=None, |
||
| 18 | delete_permission=None): |
||
| 19 | """ |
||
| 20 | Constructor |
||
| 21 | |||
| 22 | Parameters |
||
| 23 | ---------- |
||
| 24 | any_permission : boolean |
||
| 25 | True for give any permission of the specified object to the staff |
||
| 26 | user. Default value will be taken from |
||
| 27 | ``PERMISSION_DEFAULT_SPL_ANY_PERMISSION`` in |
||
| 28 | settings. |
||
| 29 | add_permission : boolean |
||
| 30 | True for give change permission of the specified object to the |
||
| 31 | staff user. |
||
| 32 | It will be ignored if :attr:`any_permission` is True. |
||
| 33 | Default value will be taken from |
||
| 34 | ``PERMISSION_DEFAULT_SPL_ADD_PERMISSION`` in |
||
| 35 | settings. |
||
| 36 | change_permission : boolean |
||
| 37 | True for give change permission of the specified object to the |
||
| 38 | staff user. |
||
| 39 | It will be ignored if :attr:`any_permission` is True. |
||
| 40 | Default value will be taken from |
||
| 41 | ``PERMISSION_DEFAULT_SPL_CHANGE_PERMISSION`` in |
||
| 42 | settings. |
||
| 43 | delete_permission : boolean |
||
| 44 | True for give delete permission of the specified object to the |
||
| 45 | staff user. |
||
| 46 | It will be ignored if :attr:`any_permission` is True. |
||
| 47 | Default value will be taken from |
||
| 48 | ``PERMISSION_DEFAULT_SPL_DELETE_PERMISSION`` in |
||
| 49 | settings. |
||
| 50 | """ |
||
| 51 | self.any_permission = any_permission |
||
| 52 | self.add_permission = add_permission |
||
| 53 | self.change_permission = change_permission |
||
| 54 | self.delete_permission = delete_permission |
||
| 55 | |||
| 56 | if self.any_permission is None: |
||
| 57 | self.any_permission = \ |
||
| 58 | settings.PERMISSION_DEFAULT_SPL_ANY_PERMISSION |
||
| 59 | if self.add_permission is None: |
||
| 60 | self.add_permission = \ |
||
| 61 | settings.PERMISSION_DEFAULT_SPL_ADD_PERMISSION |
||
| 62 | if self.change_permission is None: |
||
| 63 | self.change_permission = \ |
||
| 64 | settings.PERMISSION_DEFAULT_SPL_CHANGE_PERMISSION |
||
| 65 | if self.delete_permission is None: |
||
| 66 | self.delete_permission = \ |
||
| 67 | settings.PERMISSION_DEFAULT_SPL_DELETE_PERMISSION |
||
| 68 | |||
| 132 |