2022-12-07 10:38:03 +00:00
|
|
|
from rest_framework.request import Request
|
|
|
|
|
|
|
|
from users.models import User
|
|
|
|
from common.http import is_true
|
|
|
|
|
2022-12-09 06:03:00 +00:00
|
|
|
from perms.utils import UserPermTreeRefreshUtil
|
2022-12-09 05:05:34 +00:00
|
|
|
|
2022-12-07 10:38:03 +00:00
|
|
|
|
|
|
|
__all__ = ['RebuildTreeMixin']
|
|
|
|
|
|
|
|
|
|
|
|
class RebuildTreeMixin:
|
|
|
|
user: User
|
|
|
|
|
|
|
|
def get(self, request: Request, *args, **kwargs):
|
|
|
|
force = is_true(request.query_params.get('rebuild_tree'))
|
2022-12-09 05:05:34 +00:00
|
|
|
UserPermTreeRefreshUtil(self.user).refresh_if_need(force)
|
2022-12-07 10:38:03 +00:00
|
|
|
return super().get(request, *args, **kwargs)
|