Skip to content

Commit

Permalink
1.0beta1 (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
KingCSharp committed Apr 17, 2021
1 parent d0e6e2b commit 44d5653
Show file tree
Hide file tree
Showing 267 changed files with 2,648 additions and 53,837 deletions.
1 change: 1 addition & 0 deletions accounts/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
urlpatterns = [
path("", api_views.AccountsListView.as_view()),
path("<int:pk>/", api_views.AccountDetailView.as_view()),
path("<int:pk>/create_mail", api_views.AccountCreateMailView.as_view()),
path("comment/<int:pk>/", api_views.AccountCommentView.as_view()),
path("attachment/<int:pk>/", api_views.AccountAttachmentView.as_view()),
]
205 changes: 118 additions & 87 deletions accounts/api_views.py

Large diffs are not rendered by default.

217 changes: 0 additions & 217 deletions accounts/forms.py

This file was deleted.

17 changes: 17 additions & 0 deletions accounts/migrations/0012_remove_account_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.1.7 on 2021-03-23 14:25

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("accounts", "0011_account_company"),
]

operations = [
migrations.RemoveField(
model_name="account",
name="company",
),
]
6 changes: 1 addition & 5 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _

from common.models import User, Company
from common.models import User
from common.utils import INDCHOICES, COUNTRIES
from phonenumber_field.modelfields import PhoneNumberField
from django.utils.text import slugify
Expand Down Expand Up @@ -70,10 +70,6 @@ class Account(models.Model):
assigned_to = models.ManyToManyField(User, related_name="account_assigned_users")
teams = models.ManyToManyField(Teams, related_name="account_teams")

company = models.ForeignKey(
Company, on_delete=models.SET_NULL, null=True, blank=True
)

def __str__(self):
return self.name

Expand Down
50 changes: 32 additions & 18 deletions accounts/serializer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers
from accounts.models import Account, Email, Tags
from common.serializer import UserSerializer, CompanySerializer, AttachmentsSerializer
from common.serializer import UserSerializer, AttachmentsSerializer
from leads.serializer import LeadSerializer
from teams.serializer import TeamsSerializer
from contacts.serializer import ContactSerializer
Expand All @@ -15,7 +15,6 @@ class Meta:
class AccountSerializer(serializers.ModelSerializer):
created_by = UserSerializer()
lead = LeadSerializer()
company = CompanySerializer()
tags = TagsSerailizer(read_only=True, many=True)
assigned_to = UserSerializer(read_only=True, many=True)
contacts = ContactSerializer(read_only=True, many=True)
Expand Down Expand Up @@ -50,26 +49,44 @@ class Meta:
"contacts",
"assigned_to",
"teams",
"company",
)


class EmailSerializer(serializers.ModelSerializer):
def __init__(self, *args, **kwargs):
request_obj = kwargs.pop("request_obj", None)
super(EmailSerializer, self).__init__(*args, **kwargs)

class Meta:
model = Email
fields = (
"from_account"
"recipients"
"message_subject"
"message_body"
"timezone"
"scheduled_date_time"
"scheduled_later"
"created_on"
"from_email"
"rendered_message_body"
"message_subject",
"message_body",
"timezone",
"scheduled_date_time",
"scheduled_later",
"created_on",
"from_email",
"rendered_message_body",
)

def validate_message_body(self, message_body):
count = 0
for i in message_body:
if i == "{":
count += 1
elif i == "}":
count -= 1
if count < 0:
raise serializers.ValidationError(
"Brackets do not match, Enter valid tags."
)
if count != 0:
raise serializers.ValidationError(
"Brackets do not match, Enter valid tags."
)
return message_body


class EmailLogSerializer(serializers.ModelSerializer):
email = EmailSerializer()
Expand All @@ -96,20 +113,17 @@ def __init__(self, *args, **kwargs):
if self.instance:
self.fields["lead"].required = False
self.fields["lead"].required = False
self.company = request_obj.company

def validate_name(self, name):
if self.instance:
if self.instance.name != name:
if not Account.objects.filter(
name__iexact=name, company=self.company
).exists():
if not Account.objects.filter(name__iexact=name).exists():
return name
raise serializers.ValidationError(
"Account already exists with this name"
)
return name
if not Account.objects.filter(name__iexact=name, company=self.company).exists():
if not Account.objects.filter(name__iexact=name).exists():
return name
raise serializers.ValidationError("Account already exists with this name")

Expand Down
Loading

0 comments on commit 44d5653

Please sign in to comment.