Coverage for src/mesh/model/submission_status.py: 90%

18 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-04-28 07:45 +0000

1from __future__ import annotations 

2 

3from dataclasses import dataclass 

4from enum import Enum, unique 

5from typing import TYPE_CHECKING, Literal 

6 

7# from django.urls import reverse_lazy 

8# from django.utils.translation import gettext_lazy as _ 

9 

10# from ..views.components.button import Button 

11 

12if TYPE_CHECKING: 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true

13 from mesh.models.submission_models import Submission 

14 

15 

16@unique 

17class SubmissionStatus(Enum): 

18 """ 

19 The submission status according to the user role. 

20 """ 

21 

22 # The user role must take action. 

23 TODO = "todo" 

24 # The user role is not required to take action and the submission is not done. 

25 # Usually waiting for some other user to take action. 

26 WAITING = "waiting" 

27 # The submission is closed (accepted or declined). 

28 DONE = "done" 

29 # Error somewhere - Unsolvable status or the submission should not be accessible. 

30 ERROR = "error" 

31 

32 

33SubmissionStatusType = Literal[ 

34 SubmissionStatus.TODO, 

35 SubmissionStatus.WAITING, 

36 SubmissionStatus.DONE, 

37 SubmissionStatus.ERROR, 

38] 

39 

40 

41@dataclass 

42class SubmissionStatusData: 

43 """ 

44 Data about the submission status relative to an user role. 

45 """ 

46 

47 submission: Submission 

48 status: SubmissionStatusType 

49 # Precise description of the submission status 

50 description: str 

51 # Actions regarding the submissiosn accessible from the submission list. 

52 # shortcut_actions: list[Button] = field(default_factory=list) 

53 

54 # def get_shortcut_actions(self) -> list[Button]: 

55 # """ 

56 # Wraps self.shortcut_actions: 

57 # Return a link button to the submission if there are no shortcut actions, 

58 # otherwise the list of shortcut actions. 

59 # """ 

60 # if self.shortcut_actions: 

61 # return self.shortcut_actions 

62 # return [] 

63 # # return [self.default_action_button] 

64 

65 # @property 

66 # def default_action_button(self) -> Button: 

67 # return Button( 

68 # id=f"submission-link-{self.submission.pk}", 

69 # title=_("View Submission"), 

70 # icon_class="fa-eye", 

71 # attrs={ 

72 # "href": [ 

73 # reverse_lazy("mesh:submission_details", kwargs={"pk": self.submission.pk}) 

74 # ], 

75 # "class": ["as-button button-highlight"], 

76 # "data-tooltip": [_("Navigate to the submission page.")], 

77 # }, 

78 # )