Skip to content

Commit

Permalink
TypeError: JSON object must not be list resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
shaikhmudassir committed Oct 15, 2023
1 parent 829929d commit 8e8132d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions leads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ def get_context_data(self, **kwargs):
queryset = queryset.filter(source=params.get("source"))
if params.getlist("assigned_to"):
queryset = queryset.filter(
assigned_to__id__in=json.loads(params.get("assigned_to"))
assigned_to__id__in=params.get("assigned_to")
)
if params.get("status"):
queryset = queryset.filter(status=params.get("status"))
if params.get("tags"):
queryset = queryset.filter(tags__in=json.loads(params.get("tags")))
queryset = queryset.filter(tags__in=params.get("tags"))
if params.get("city"):
queryset = queryset.filter(city__icontains=params.get("city"))
if params.get("email"):
Expand Down Expand Up @@ -165,7 +165,7 @@ def post(self, request, *args, **kwargs):
lead_obj = serializer.save(created_by=request.profile.user
, org=request.profile.org)
if data.get("tags",None):
tags = json.loads(data.get("tags"))
tags = data.get("tags")
for t in tags:
tag = Tags.objects.filter(slug=t.lower())
if tag.exists():
Expand All @@ -176,7 +176,7 @@ def post(self, request, *args, **kwargs):

if data.get("contacts",None):
obj_contact = Contact.objects.filter(
id__in=json.loads(data.get("contacts")), org=request.profile.org
id__in=data.get("contacts"), org=request.profile.org
)
lead_obj.contacts.add(*obj_contact)

Expand All @@ -195,12 +195,12 @@ def post(self, request, *args, **kwargs):
attachment.save()

if data.get("teams",None):
teams_list = json.loads(data.get("teams"))
teams_list = data.get("teams")
teams = Teams.objects.filter(id__in=teams_list, org=request.profile.org)
lead_obj.teams.add(*teams)

if data.get("assigned_to",None):
assinged_to_list = json.loads(data.get("assigned_to"))
assinged_to_list = data.get("assigned_to")
profiles = Profile.objects.filter(
id__in=assinged_to_list, org=request.profile.org
)
Expand Down Expand Up @@ -235,7 +235,7 @@ def post(self, request, *args, **kwargs):
account_object.tags.add(tag)

if data.get("assigned_to",None):
assigned_to_list = json.loads(data.getlist("assigned_to"))
assigned_to_list = data.getlist("assigned_to")
recipients = assigned_to_list
send_email_to_assigned_user.delay(
recipients,
Expand Down Expand Up @@ -438,7 +438,7 @@ def put(self, request, pk, **kwargs):
)
lead_obj.tags.clear()
if params.get("tags"):
tags = json.loads(params.get("tags"))
tags = params.get("tags")
# for t in tags:
# tag,_ = Tags.objects.get_or_create(name=t)
# lead_obj.tags.add(tag)
Expand Down Expand Up @@ -475,13 +475,13 @@ def put(self, request, pk, **kwargs):

lead_obj.teams.clear()
if params.get("teams"):
teams_list = json.loads(params.get("teams"))
teams_list = params.get("teams")
teams = Teams.objects.filter(id__in=teams_list, org=request.profile.org)
lead_obj.teams.add(*teams)

lead_obj.assigned_to.clear()
if params.get("assigned_to"):
assinged_to_list = json.loads(params.get("assigned_to"))
assinged_to_list = params.get("assigned_to")
profiles = Profile.objects.filter(
id__in=assinged_to_list, org=request.profile.org
)
Expand Down Expand Up @@ -516,7 +516,7 @@ def put(self, request, pk, **kwargs):
account_object.tags.add(tag)
if params.get("assigned_to"):
# account_object.assigned_to.add(*params.getlist('assigned_to'))
assigned_to_list = json.loads(params.get("assigned_to"))
assigned_to_list = params.get("assigned_to")
recipients = assigned_to_list
send_email_to_assigned_user.delay(
recipients,
Expand Down

0 comments on commit 8e8132d

Please sign in to comment.