16
16
from cases .tasks import send_email_to_assigned_user
17
17
from common .models import Attachments , Comment , Profile
18
18
19
- # from common.custom_auth import JSONWebTokenAuthentication
19
+ from common .external_auth import CustomDualAuthentication
20
20
from common .serializer import AttachmentsSerializer , CommentSerializer
21
21
from common .utils import CASE_TYPE , PRIORITY_CHOICE , STATUS_CHOICE
22
22
from contacts .models import Contact
25
25
26
26
27
27
class CaseListView (APIView , LimitOffsetPagination ):
28
- # authentication_classes = (JSONWebTokenAuthentication ,)
28
+ authentication_classes = (CustomDualAuthentication ,)
29
29
permission_classes = (IsAuthenticated ,)
30
30
model = Case
31
31
@@ -37,13 +37,13 @@ def get_context_data(self, **kwargs):
37
37
profiles = Profile .objects .filter (is_active = True , org = self .request .profile .org )
38
38
if self .request .profile .role != "ADMIN" and not self .request .profile .is_admin :
39
39
queryset = queryset .filter (
40
- Q (created_by = self .request .profile ) | Q (assigned_to = self .request .profile )
40
+ Q (created_by = self .request .profile . user ) | Q (assigned_to = self .request .profile )
41
41
).distinct ()
42
42
accounts = accounts .filter (
43
- Q (created_by = self .request .profile ) | Q (assigned_to = self .request .profile )
43
+ Q (created_by = self .request .profile . user ) | Q (assigned_to = self .request .profile )
44
44
).distinct ()
45
45
contacts = contacts .filter (
46
- Q (created_by = self .request .profile ) | Q (assigned_to = self .request .profile )
46
+ Q (created_by = self .request .profile . user ) | Q (assigned_to = self .request .profile )
47
47
).distinct ()
48
48
profiles = profiles .filter (role = "ADMIN" )
49
49
@@ -97,26 +97,26 @@ def post(self, request, *args, **kwargs):
97
97
serializer = CaseCreateSerializer (data = params , request_obj = request )
98
98
if serializer .is_valid ():
99
99
cases_obj = serializer .save (
100
- created_by = request .profile ,
100
+ created_by = request .profile . user ,
101
101
org = request .profile .org ,
102
102
closed_on = params .get ("closed_on" ),
103
103
case_type = params .get ("case_type" ),
104
104
)
105
105
106
106
if params .get ("contacts" ):
107
- contacts_list = json . loads ( params .get ("contacts" ) )
107
+ contacts_list = params .get ("contacts" )
108
108
contacts = Contact .objects .filter (id__in = contacts_list , org = request .profile .org )
109
109
if contacts :
110
110
cases_obj .contacts .add (* contacts )
111
111
112
112
if params .get ("teams" ):
113
- teams_list = json . loads ( params .get ("teams" ) )
113
+ teams_list = params .get ("teams" )
114
114
teams = Teams .objects .filter (id__in = teams_list , org = request .profile .org )
115
115
if teams .exists ():
116
116
cases_obj .teams .add (* teams )
117
117
118
118
if params .get ("assigned_to" ):
119
- assinged_to_list = json . loads ( params .get ("assigned_to" ) )
119
+ assinged_to_list = params .get ("assigned_to" )
120
120
profiles = Profile .objects .filter (
121
121
id__in = assinged_to_list , org = request .profile .org , is_active = True
122
122
)
@@ -125,7 +125,7 @@ def post(self, request, *args, **kwargs):
125
125
126
126
if self .request .FILES .get ("case_attachment" ):
127
127
attachment = Attachments ()
128
- attachment .created_by = self .request .profile
128
+ attachment .created_by = self .request .profile . user
129
129
attachment .file_name = self .request .FILES .get ("case_attachment" ).name
130
130
attachment .cases = cases_obj
131
131
attachment .attachment = self .request .FILES .get ("case_attachment" )
@@ -148,7 +148,7 @@ def post(self, request, *args, **kwargs):
148
148
149
149
150
150
class CaseDetailView (APIView ):
151
- # authentication_classes = (JSONWebTokenAuthentication ,)
151
+ authentication_classes = (CustomDualAuthentication ,)
152
152
permission_classes = (IsAuthenticated ,)
153
153
model = Case
154
154
@@ -194,21 +194,21 @@ def put(self, request, pk, format=None):
194
194
)
195
195
cases_object .contacts .clear ()
196
196
if params .get ("contacts" ):
197
- contacts_list = json . loads ( params .get ("contacts" ) )
197
+ contacts_list = params .get ("contacts" )
198
198
contacts = Contact .objects .filter (id__in = contacts_list , org = request .profile .org )
199
199
if contacts :
200
200
cases_object .contacts .add (* contacts )
201
201
202
202
cases_object .teams .clear ()
203
203
if params .get ("teams" ):
204
- teams_list = json . loads ( params .get ("teams" ) )
204
+ teams_list = params .get ("teams" )
205
205
teams = Teams .objects .filter (id__in = teams_list , org = request .profile .org )
206
206
if teams .exists ():
207
207
cases_object .teams .add (* teams )
208
208
209
209
cases_object .assigned_to .clear ()
210
210
if params .get ("assigned_to" ):
211
- assinged_to_list = json . loads ( params .get ("assigned_to" ) )
211
+ assinged_to_list = params .get ("assigned_to" )
212
212
profiles = Profile .objects .filter (
213
213
id__in = assinged_to_list , org = request .profile .org , is_active = True
214
214
)
@@ -217,7 +217,7 @@ def put(self, request, pk, format=None):
217
217
218
218
if self .request .FILES .get ("case_attachment" ):
219
219
attachment = Attachments ()
220
- attachment .created_by = self .request .profile
220
+ attachment .created_by = self .request .profile . user
221
221
attachment .file_name = self .request .FILES .get ("case_attachment" ).name
222
222
attachment .case = cases_object
223
223
attachment .attachment = self .request .FILES .get ("case_attachment" )
@@ -366,7 +366,7 @@ def post(self, request, pk, **kwargs):
366
366
367
367
if self .request .FILES .get ("case_attachment" ):
368
368
attachment = Attachments ()
369
- attachment .created_by = self .request .profile
369
+ attachment .created_by = self .request .profile . user
370
370
attachment .file_name = self .request .FILES .get ("case_attachment" ).name
371
371
attachment .case = self .cases_obj
372
372
attachment .attachment = self .request .FILES .get ("case_attachment" )
@@ -387,7 +387,7 @@ def post(self, request, pk, **kwargs):
387
387
388
388
class CaseCommentView (APIView ):
389
389
model = Comment
390
- # authentication_classes = (JSONWebTokenAuthentication ,)
390
+ authentication_classes = (CustomDualAuthentication ,)
391
391
permission_classes = (IsAuthenticated ,)
392
392
393
393
def get_object (self , pk ):
@@ -450,7 +450,7 @@ def delete(self, request, pk, format=None):
450
450
451
451
class CaseAttachmentView (APIView ):
452
452
model = Attachments
453
- # authentication_classes = (JSONWebTokenAuthentication ,)
453
+ authentication_classes = (CustomDualAuthentication ,)
454
454
permission_classes = (IsAuthenticated ,)
455
455
456
456
@extend_schema (
0 commit comments