fix lowercase: duplicate key value violates unique constraint "accounts_tags_slug_key" (#387)

Co-authored-by: Ashwin Kumar <ashwin@micropyramid.com>
This commit is contained in:
Fabrizio 2020-06-18 16:31:56 +02:00 committed by GitHub
parent 4f0e1ae7e1
commit 2d236879ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -190,11 +190,11 @@ class CreateAccountView(SalesAccessRequiredMixin, LoginRequiredMixin, CreateView
tags = self.request.POST.get("tags")
splitted_tags = tags.split(",")
for t in splitted_tags:
tag = Tags.objects.filter(name=t.lower())
tag = Tags.objects.filter(name=t)
if tag:
tag = tag[0]
else:
tag = Tags.objects.create(name=t.lower())
tag = Tags.objects.create(name=t)
account_object.tags.add(tag)
if self.request.POST.getlist("contacts", []):
account_object.contacts.add(*self.request.POST.getlist("contacts"))
@ -768,3 +768,4 @@ def get_email_data_for_account(request):
return JsonResponse(ctx)
else:
return JsonResponse({"error": True, "data": "No emails found."})