Coverage for sites/ptf_tools/comments_moderation/mixins.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-06-19 08:36 +0000

1from django.http import HttpRequest 

2from django.utils import translation 

3 

4from comments_views.core.mixins import AbstractCommentRightsMixin 

5 

6from .rights import ModeratorUserRights 

7 

8 

9class ModeratorCommentRightsMixin(AbstractCommentRightsMixin): 

10 @property 

11 def rights_class(self) -> type[ModeratorUserRights]: 

12 return ModeratorUserRights 

13 

14 

15class ForceLanguageMixin: 

16 """ 

17 Forces the language to English. 

18 

19 Trammel (ptf_tools) has internationalization enabled and we need to 

20 force the comments_moderation app's language to English. 

21 """ 

22 

23 def dispatch(self, request: HttpRequest, *args, **kwargs): 

24 translation.activate("en") 

25 return super().dispatch(request, *args, **kwargs) # type:ignore