Skip to content

Commit 4bff7b9

Browse files
authored
kanban
kanban
2 parents 118f19e + 1413685 commit 4bff7b9

File tree

361 files changed

+41284
-32192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

361 files changed

+41284
-32192
lines changed

backend/accounts/migrations/0001_initial.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class Migration(migrations.Migration):
9-
109
initial = True
1110

1211
dependencies = []

backend/accounts/migrations/0002_initial.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class Migration(migrations.Migration):
9-
109
initial = True
1110

1211
dependencies = [

backend/accounts/migrations/0003_add_tags_related_name.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
("accounts", "0002_initial"),
109
("common", "0002_enable_rls"),

backend/accounts/migrations/0004_remove_phonenumberfield.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
("accounts", "0003_add_tags_related_name"),
109
]

backend/accounts/migrations/0005_add_currency_fields.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class Migration(migrations.Migration):
9-
109
dependencies = [
1110
("accounts", "0004_remove_phonenumberfield"),
1211
migrations.swappable_dependency(settings.AUTH_USER_MODEL),

backend/accounts/migrations/0006_add_enterprise_constraints.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,23 @@ def cleanup_duplicate_account_names(apps, schema_editor):
1313
Find duplicate account names (case-insensitive) within each org
1414
and append a numeric suffix to make them unique.
1515
"""
16-
Account = apps.get_model('accounts', 'Account')
16+
Account = apps.get_model("accounts", "Account")
1717

1818
# Find duplicates: group by lower(name) + org, having count > 1
1919
duplicates = (
20-
Account.objects
21-
.annotate(name_lower=Lower('name'))
22-
.values('name_lower', 'org_id')
23-
.annotate(count=Count('id'))
20+
Account.objects.annotate(name_lower=Lower("name"))
21+
.values("name_lower", "org_id")
22+
.annotate(count=Count("id"))
2423
.filter(count__gt=1)
2524
)
2625

2726
for dup in duplicates:
2827
# Get all accounts with this name in this org, ordered by created_at
2928
accounts = list(
30-
Account.objects
31-
.filter(org_id=dup['org_id'])
32-
.annotate(name_lower=Lower('name'))
33-
.filter(name_lower=dup['name_lower'])
34-
.order_by('created_at')
29+
Account.objects.filter(org_id=dup["org_id"])
30+
.annotate(name_lower=Lower("name"))
31+
.filter(name_lower=dup["name_lower"])
32+
.order_by("created_at")
3533
)
3634

3735
# Keep the first one (oldest), rename the rest
@@ -40,17 +38,19 @@ def cleanup_duplicate_account_names(apps, schema_editor):
4038
new_name = f"{account.name} ({i})"
4139
# Ensure the new name is also unique
4240
counter = i
43-
while Account.objects.filter(org_id=account.org_id, name__iexact=new_name).exists():
41+
while Account.objects.filter(
42+
org_id=account.org_id, name__iexact=new_name
43+
).exists():
4444
counter += 1
4545
new_name = f"{original_name} ({counter})"
4646
account.name = new_name
47-
account.save(update_fields=['name'])
47+
account.save(update_fields=["name"])
4848
print(f" Renamed duplicate account: '{original_name}' -> '{new_name}'")
4949

5050

5151
def cleanup_negative_revenue(apps, schema_editor):
5252
"""Set negative annual_revenue values to NULL."""
53-
Account = apps.get_model('accounts', 'Account')
53+
Account = apps.get_model("accounts", "Account")
5454
updated = Account.objects.filter(annual_revenue__lt=0).update(annual_revenue=None)
5555
if updated:
5656
print(f" Set {updated} negative annual_revenue values to NULL")
@@ -62,7 +62,6 @@ def reverse_noop(apps, schema_editor):
6262

6363

6464
class Migration(migrations.Migration):
65-
6665
dependencies = [
6766
("accounts", "0005_add_currency_fields"),
6867
("common", "0008_enable_rls_product_invoice_line_item"),

backend/accounts/serializer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ def get_tasks(self, obj):
5050
@extend_schema_field(list)
5151
def get_opportunities(self, obj):
5252
"""Return opportunities linked to this account"""
53-
return [{"id": str(o.id), "name": o.name, "stage": o.stage, "amount": str(o.amount) if o.amount else "0"} for o in obj.opportunities.all()]
53+
return [
54+
{
55+
"id": str(o.id),
56+
"name": o.name,
57+
"stage": o.stage,
58+
"amount": str(o.amount) if o.amount else "0",
59+
}
60+
for o in obj.opportunities.all()
61+
]
5462

5563
class Meta:
5664
model = Account

backend/accounts/tasks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,3 @@ def send_email_to_assigned_user(recipients, account_id, org_id):
8585
msg = EmailMessage(subject, html_content, to=recipients_list)
8686
msg.content_subtype = "html"
8787
msg.send()
88-
89-

backend/accounts/views.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ def get_context_data(self, **kwargs):
8585
if params.get("search"):
8686
queryset = queryset.filter(name__icontains=params.get("search"))
8787
if params.get("created_at__gte"):
88-
queryset = queryset.filter(created_at__gte=params.get("created_at__gte"))
88+
queryset = queryset.filter(
89+
created_at__gte=params.get("created_at__gte")
90+
)
8991
if params.get("created_at__lte"):
90-
queryset = queryset.filter(created_at__lte=params.get("created_at__lte"))
92+
queryset = queryset.filter(
93+
created_at__lte=params.get("created_at__lte")
94+
)
9195

9296
context = {}
9397

@@ -187,27 +191,33 @@ def post(self, request, *args, **kwargs):
187191

188192
# Handle M2M relationships using utilities
189193
handle_m2m_assignment(
190-
account_object, 'contacts', data.get('contacts'),
191-
Contact, request.profile.org
194+
account_object,
195+
"contacts",
196+
data.get("contacts"),
197+
Contact,
198+
request.profile.org,
192199
)
193-
tags = get_or_create_tags(data.get('tags'), request.profile.org)
200+
tags = get_or_create_tags(data.get("tags"), request.profile.org)
194201
if tags:
195202
account_object.tags.add(*tags)
196203
handle_m2m_assignment(
197-
account_object, 'teams', data.get('teams'),
198-
Teams, request.profile.org
204+
account_object, "teams", data.get("teams"), Teams, request.profile.org
199205
)
200206
handle_m2m_assignment(
201-
account_object, 'assigned_to', data.get('assigned_to'),
202-
Profile, request.profile.org, extra_filters={'is_active': True}
207+
account_object,
208+
"assigned_to",
209+
data.get("assigned_to"),
210+
Profile,
211+
request.profile.org,
212+
extra_filters={"is_active": True},
203213
)
204214

205215
# Handle attachment
206216
if self.request.FILES.get("account_attachment"):
207217
create_attachment(
208218
request.FILES.get("account_attachment"),
209219
account_object,
210-
request.profile
220+
request.profile,
211221
)
212222

213223
recipients = list(
@@ -286,7 +296,9 @@ def put(self, request, pk, format=None):
286296
account_object.tags.clear()
287297
if data.get("tags"):
288298
tags = json.loads(data.get("tags"))
289-
tag_objs = Tags.objects.filter(id__in=tags, org=request.profile.org, is_active=True)
299+
tag_objs = Tags.objects.filter(
300+
id__in=tags, org=request.profile.org, is_active=True
301+
)
290302
account_object.tags.add(*tag_objs)
291303

292304
account_object.teams.clear()
@@ -546,7 +558,10 @@ def patch(self, request, pk, format=None):
546558
account_object = self.get_object(pk=pk)
547559
if account_object.org != request.profile.org:
548560
return Response(
549-
{"error": True, "errors": "User company does not match with header...."},
561+
{
562+
"error": True,
563+
"errors": "User company does not match with header....",
564+
},
550565
status=status.HTTP_403_FORBIDDEN,
551566
)
552567
if self.request.profile.role != "ADMIN" and not self.request.profile.is_admin:
@@ -591,7 +606,9 @@ def patch(self, request, pk, format=None):
591606
if tags:
592607
if isinstance(tags, str):
593608
tags = json.loads(tags)
594-
tag_objs = Tags.objects.filter(id__in=tags, org=request.profile.org, is_active=True)
609+
tag_objs = Tags.objects.filter(
610+
id__in=tags, org=request.profile.org, is_active=True
611+
)
595612
account_object.tags.add(*tag_objs)
596613

597614
if "teams" in data:
@@ -600,7 +617,9 @@ def patch(self, request, pk, format=None):
600617
if teams_list:
601618
if isinstance(teams_list, str):
602619
teams_list = json.loads(teams_list)
603-
teams = Teams.objects.filter(id__in=teams_list, org=request.profile.org)
620+
teams = Teams.objects.filter(
621+
id__in=teams_list, org=request.profile.org
622+
)
604623
account_object.teams.add(*teams)
605624

606625
if "assigned_to" in data:

0 commit comments

Comments
 (0)