| Conditions | 5 |
| Total Lines | 54 |
| Lines | 54 |
| 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 author as django user model. |
||
| 27 | You can specify the related object with '__' like django queryset |
||
| 28 | filter. |
||
| 29 | Default value will be taken from |
||
| 30 | ``PERMISSION_DEFAULT_APL_FIELD_NAME`` in |
||
| 31 | settings. |
||
| 32 | any_permission : boolean |
||
| 33 | True for give any permission of the specified object to the author |
||
| 34 | Default value will be taken from |
||
| 35 | ``PERMISSION_DEFAULT_APL_ANY_PERMISSION`` in |
||
| 36 | settings. |
||
| 37 | change_permission : boolean |
||
| 38 | True for give change permission of the specified object to the |
||
| 39 | author. |
||
| 40 | It will be ignored if :attr:`any_permission` is True. |
||
| 41 | Default value will be taken from |
||
| 42 | ``PERMISSION_DEFAULT_APL_CHANGE_PERMISSION`` in |
||
| 43 | settings. |
||
| 44 | delete_permission : boolean |
||
| 45 | True for give delete permission of the specified object to the |
||
| 46 | author. |
||
| 47 | It will be ignored if :attr:`any_permission` is True. |
||
| 48 | Default value will be taken from |
||
| 49 | ``PERMISSION_DEFAULT_APL_DELETE_PERMISSION`` in |
||
| 50 | settings. |
||
| 51 | """ |
||
| 52 | self.field_name = field_name |
||
| 53 | self.any_permission = any_permission |
||
| 54 | self.change_permission = change_permission |
||
| 55 | self.delete_permission = delete_permission |
||
| 56 | |||
| 57 | if self.field_name is None: |
||
| 58 | self.field_name = \ |
||
| 59 | settings.PERMISSION_DEFAULT_APL_FIELD_NAME |
||
| 60 | if self.any_permission is None: |
||
| 61 | self.any_permission = \ |
||
| 62 | settings.PERMISSION_DEFAULT_APL_ANY_PERMISSION |
||
| 63 | if self.change_permission is None: |
||
| 64 | self.change_permission = \ |
||
| 65 | settings.PERMISSION_DEFAULT_APL_CHANGE_PERMISSION |
||
| 66 | if self.delete_permission is None: |
||
| 67 | self.delete_permission = \ |
||
| 68 | settings.PERMISSION_DEFAULT_APL_DELETE_PERMISSION |
||
| 69 | |||
| 134 |