Coverage for src/comments_moderation/mixins.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-04-09 14:54 +0000

1from comments_views.core.mixins import AbstractCommentRightsMixin 

2from django.http import HttpRequest 

3from django.utils import translation 

4 

5from .rights import ModeratorUserRights 

6 

7 

8class ModeratorCommentRightsMixin(AbstractCommentRightsMixin): 

9 @property 

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

11 return ModeratorUserRights 

12 

13 

14class ForceLanguageMixin: 

15 """ 

16 Forces the language to English. 

17 

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

19 force the comments_moderation app's language to English. 

20 """ 

21 

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

23 translation.activate("en") 

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