Coverage for sites/ptf_tools/comments_moderation/mixins.py: 100%
12 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-11-04 17:46 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-11-04 17:46 +0000
1from django.http import HttpRequest
2from django.utils import translation
4from comments_views.core.mixins import AbstractCommentRightsMixin
6from .rights import ModeratorUserRights
9class ModeratorCommentRightsMixin(AbstractCommentRightsMixin):
10 @property
11 def rights_class(self) -> type[ModeratorUserRights]:
12 return ModeratorUserRights
15class ForceLanguageMixin:
16 """
17 Forces the language to English.
19 Trammel (ptf_tools) has internationalization enabled and we need to
20 force the comments_moderation app's language to English.
21 """
23 def dispatch(self, request: HttpRequest, *args, **kwargs):
24 translation.activate("en")
25 return super().dispatch(request, *args, **kwargs) # type:ignore