Skip to content

Commit

Permalink
feat: fill name in sync subscription
Browse files Browse the repository at this point in the history
vncsna committed Feb 2, 2024
1 parent 3e6d377 commit 742c71d
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bd_api/apps/account/models.py
Original file line number Diff line number Diff line change
@@ -346,7 +346,11 @@ def get_short_name(self):
get_short_name.short_description = "nome"

def get_full_name(self):
return f"{self.first_name} {self.last_name}"
if self.first_name and self.last_name:
return f"{self.first_name} {self.last_name}"
if self.first_name:
return self.first_name
return self.username

get_full_name.short_description = "nome completo"

4 changes: 4 additions & 0 deletions bd_api/apps/account/tasks.py
Original file line number Diff line number Diff line change
@@ -33,8 +33,12 @@ def sync_subscription_task(
admin = admin or Account.objects.filter(
email=subscription.customer.email,
).first() # fmt: skip
full_name = subscription.customer.name.title()
first_name, last_name = full_name.split(" ")
admin = admin or Account.objects.create(
is_active=True,
last_name=last_name,
first_name=first_name,
email=subscription.customer.email,
username=subscription.customer.email.split("@")[0],
)

0 comments on commit 742c71d

Please sign in to comment.