mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 20:09:25 +00:00
deprecate CanCreateMixin
Les motifs de cette déprécation sont indiqués dans la documentation. Le mixin a été remplacé par `PermissionRequiredMixin` dans les endroits où ce remplacement était aisé.
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#
|
||||
|
||||
import types
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Any, LiteralString
|
||||
|
||||
from django.contrib.auth.mixins import AccessMixin, PermissionRequiredMixin
|
||||
@ -148,6 +149,24 @@ class CanCreateMixin(View):
|
||||
to create the object of the view.
|
||||
"""
|
||||
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
warnings.warn(
|
||||
f"{cls.__name__} is deprecated and should be replaced "
|
||||
"by other permission verification mecanism.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
super().__init_subclass__(**kwargs)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
f"{self.__class__.__name__} is deprecated and should be replaced "
|
||||
"by other permission verification mecanism.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
res = super().dispatch(request, *arg, **kwargs)
|
||||
if not request.user.is_authenticated:
|
||||
|
Reference in New Issue
Block a user