130 | | This will be integrated into the GenericAuthorization SoC project. More info to come. |
| 130 | In the next week, GenericAuthorization and row level permissions will be merged. Therefore, I have shown two different methods of checking for permissions, one using the generic authorization and the currently implemented technique. |
| 131 | |
| 132 | The current method uses the has_perm method in the User model. Note: The object parameter is optional, this is to allow backwards compatibility. |
| 133 | |
| 134 | Example: |
| 135 | {{{ |
| 136 | #!python |
| 137 | ... |
| 138 | user.has_perm("can_mine", object=mineral) |
| 139 | ... |
| 140 | }}} |
| 141 | |
| 142 | This will return either True or False depending on if the user has the correct permission. It will return false if the user has a negative row level permission on the object. |
| 143 | |
| 144 | This will also check group row level permissions. If the user is in two groups, the first having a positive row level permission and the second having a negative row level permission, it will take the positive row level permission over the negative. |
| 145 | |
| 146 | '''Second method using GenericAuthorization will be written after the merger''' |
| 147 | |