| Conditions | 6 |
| Total Lines | 59 |
| 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 | group_names, |
||
| 16 | any_permission=None, |
||
| 17 | add_permission=None, |
||
| 18 | change_permission=None, |
||
| 19 | delete_permission=None): # noqa |
||
| 20 | """ |
||
| 21 | Constructor |
||
| 22 | |||
| 23 | Parameters |
||
| 24 | ---------- |
||
| 25 | group_names : string or list |
||
| 26 | A group name list of this permission logic treat |
||
| 27 | any_permission : boolean |
||
| 28 | True for give any permission to the user_obj |
||
| 29 | Default value will be taken from |
||
| 30 | ``PERMISSION_DEFAULT_GIPL_ANY_PERMISSION`` in |
||
| 31 | settings. |
||
| 32 | add_permission : boolean |
||
| 33 | True for give add permission to the user_obj. |
||
| 34 | It will be ignored if :attr:`any_permission` is True. |
||
| 35 | Default value will be taken from |
||
| 36 | ``PERMISSION_DEFAULT_GIPL_ADD_PERMISSION`` in |
||
| 37 | settings. |
||
| 38 | change_permission : boolean |
||
| 39 | True for give change permission of the specified object to the |
||
| 40 | user_obj. |
||
| 41 | It will be ignored if :attr:`any_permission` is True. |
||
| 42 | Default value will be taken from |
||
| 43 | ``PERMISSION_DEFAULT_GIPL_CHANGE_PERMISSION`` in |
||
| 44 | settings. |
||
| 45 | delete_permission : boolean |
||
| 46 | True for give delete permission of the specified object to the |
||
| 47 | user_obj. |
||
| 48 | It will be ignored if :attr:`any_permission` is True. |
||
| 49 | Default value will be taken from |
||
| 50 | ``PERMISSION_DEFAULT_GIPL_DELETE_PERMISSION`` in |
||
| 51 | settings. |
||
| 52 | """ |
||
| 53 | self.group_names = group_names |
||
| 54 | if not isinstance(self.group_names, (list, tuple)): |
||
| 55 | self.group_names = [self.group_names] |
||
| 56 | self.any_permission = any_permission |
||
| 57 | self.add_permission = add_permission |
||
| 58 | self.change_permission = change_permission |
||
| 59 | self.delete_permission = delete_permission |
||
| 60 | |||
| 61 | if self.any_permission is None: |
||
| 62 | self.any_permission = \ |
||
| 63 | settings.PERMISSION_DEFAULT_GIPL_ANY_PERMISSION |
||
| 64 | if self.add_permission is None: |
||
| 65 | self.add_permission = \ |
||
| 66 | settings.PERMISSION_DEFAULT_GIPL_ADD_PERMISSION |
||
| 67 | if self.change_permission is None: |
||
| 68 | self.change_permission = \ |
||
| 69 | settings.PERMISSION_DEFAULT_GIPL_CHANGE_PERMISSION |
||
| 70 | if self.delete_permission is None: |
||
| 71 | self.delete_permission = \ |
||
| 72 | settings.PERMISSION_DEFAULT_GIPL_DELETE_PERMISSION |
||
| 73 | |||
| 139 |