Merge branch 'group-auto-leave-enhancements' into 'v2.9.x'

Group auto leave enhancements

See merge request allianceauth/allianceauth!1369
This commit is contained in:
Ariel Rin 2021-11-27 03:45:31 +00:00
commit 8b8dcc0127
3 changed files with 8 additions and 15 deletions

View File

@ -388,7 +388,7 @@ def group_request_leave(request, group_id):
logger.info(f"{request.user} attempted to leave {group} but already has an pending leave request.") logger.info(f"{request.user} attempted to leave {group} but already has an pending leave request.")
messages.warning(request, _("You already have a pending leave request for that group.")) messages.warning(request, _("You already have a pending leave request for that group."))
return redirect("groupmanagement:groups") return redirect("groupmanagement:groups")
if getattr(settings, 'AUTO_LEAVE', False): if getattr(settings, 'GROUPMANAGEMENT_AUTO_LEAVE', False):
logger.info(f"{request.user} leaving joinable group {group} due to auto_leave") logger.info(f"{request.user} leaving joinable group {group} due to auto_leave")
request_info = request.user.username + ":" + group.name request_info = request.user.username + ":" + group.name
log = RequestLog(request_type=True, group=group, request_info=request_info, action=1, request_actor=request.user) log = RequestLog(request_type=True, group=group, request_info=request_info, action=1, request_actor=request.user)

View File

@ -41,11 +41,13 @@ Here is a list of available settings for Group Management. They can be configure
Note that all settings are optional and the app will use the documented default settings if they are not used. Note that all settings are optional and the app will use the documented default settings if they are not used.
```eval_rst ```eval_rst
+---------------------------------------------+---------------------------------------------------------------------------+------------+ +---------------------------------------------+-------------------------------------------------------------------------------------------+------------+
| Name | Description | Default | | Name | Description | Default |
+=============================================+===========================================================================+============+ +=============================================+===========================================================================================+============+
| ``GROUPMANAGEMENT_AUTO_LEAVE`` | Group members can leave their group without needing confirmation from their group leaders | ``False`` |
+---------------------------------------------+-------------------------------------------------------------------------------------------+------------+
| ``GROUPMANAGEMENT_REQUESTS_NOTIFICATION`` | Send Auth notifications to all group leaders for join and leave requests. | ``False`` | | ``GROUPMANAGEMENT_REQUESTS_NOTIFICATION`` | Send Auth notifications to all group leaders for join and leave requests. | ``False`` |
+---------------------------------------------+---------------------------------------------------------------------------+------------+ +---------------------------------------------+-------------------------------------------------------------------------------------------+------------+
``` ```
## Permissions ## Permissions

View File

@ -48,12 +48,3 @@ When a user loses this permission, they will be removed from all groups _except_
.. note:: .. note::
By default, the ``groupmanagement.request_groups`` permission is applied to the ``Member`` group. In most instances this, and perhaps adding it to the ``Blue`` group, should be all that is ever needed. It is unsupported and NOT advisable to apply this permission to a public group. See #697 for more information. By default, the ``groupmanagement.request_groups`` permission is applied to the ``Member`` group. In most instances this, and perhaps adding it to the ``Blue`` group, should be all that is ever needed. It is unsupported and NOT advisable to apply this permission to a public group. See #697 for more information.
``` ```
### Auto Leave
By default in AA, Both requests and leaves for non-open groups must be approved by a group manager. If you wish to allow users to leave groups without requiring approvals, add the following lines to your `local.py`
```python
## Allows users to freely leave groups without requiring approval.
AUTO_LEAVE = True
```