1
1
from django .core .exceptions import ObjectDoesNotExist
2
- from rest_framework import status
3
- from rest_framework .decorators import action
4
2
from rest_framework .exceptions import NotFound
5
3
from rest_framework .permissions import IsAuthenticated
6
- from rest_framework .response import Response
7
4
from rest_framework .viewsets import ModelViewSet
8
5
9
- from apps .alerts .models import AlertGroup , CustomButton
10
- from apps .alerts .tasks .custom_button_result import custom_button_result
11
- from apps .api .permissions import MODIFY_ACTIONS , READ_ACTIONS , ActionPermission , AnyRole , IsAdmin , IsAdminOrEditor
6
+ from apps .alerts .models import CustomButton
7
+ from apps .api .permissions import MODIFY_ACTIONS , READ_ACTIONS , ActionPermission , AnyRole , IsAdmin
12
8
from apps .api .serializers .custom_button import CustomButtonSerializer
13
9
from apps .auth_token .auth import PluginAuthentication
14
- from common .api_helpers .exceptions import BadRequest
15
10
from common .api_helpers .mixins import PublicPrimaryKeyMixin , TeamFilteringMixin
16
11
from common .insight_log import EntityEvent , write_resource_insight_log
17
12
@@ -21,7 +16,6 @@ class CustomButtonView(TeamFilteringMixin, PublicPrimaryKeyMixin, ModelViewSet):
21
16
permission_classes = (IsAuthenticated , ActionPermission )
22
17
action_permissions = {
23
18
IsAdmin : MODIFY_ACTIONS ,
24
- IsAdminOrEditor : ("action" ,),
25
19
AnyRole : READ_ACTIONS ,
26
20
}
27
21
@@ -85,19 +79,3 @@ def perform_destroy(self, instance):
85
79
event = EntityEvent .DELETED ,
86
80
)
87
81
instance .delete ()
88
-
89
- @action (detail = True , methods = ["post" ])
90
- def action (self , request , pk ):
91
- alert_group_id = request .query_params .get ("alert_group" , None )
92
- if alert_group_id is not None :
93
- custom_button = self .get_object ()
94
- try :
95
- alert_group = AlertGroup .unarchived_objects .get (
96
- public_primary_key = alert_group_id , channel = custom_button .alert_receive_channel
97
- )
98
- custom_button_result .apply_async ((custom_button .pk , alert_group .pk , self .request .user .pk ))
99
- except AlertGroup .DoesNotExist :
100
- raise BadRequest (detail = "AlertGroup does not exist or archived" )
101
- return Response (status = status .HTTP_200_OK )
102
- else :
103
- raise BadRequest (detail = "AlertGroup is required" )
0 commit comments