Skip to content
Closed

Dev #747

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions backend/apps/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.utils.translation import gettext_lazy
from faker import Faker

from backend.apps.account.models import Account, BDGroup, BDRole, Career, Subscription
from backend.apps.account.models import Account, BDGroup, BDRole, Team, Role, Career, Subscription
from backend.apps.account.tasks import sync_subscription_task


Expand Down Expand Up @@ -301,9 +301,52 @@ def is_subscriber(self, instance):
is_subscriber.short_description = "Subscriber"


class TeamAdmin(admin.ModelAdmin):
list_display = (
"name",
"slug",
"description",
)
search_fields = (
"name",
"slug",
)
readonly_fields = ("created_at", "updated_at")
ordering = ["name"]


class RoleAdmin(admin.ModelAdmin):
list_display = (
"name",
"slug",
"description",
)
search_fields = (
"name",
"slug",
)
readonly_fields = ("created_at", "updated_at")
ordering = ["name"]


class CareerAdmin(admin.ModelAdmin):
list_display = ("account", "team", "level", "role", "start_at", "end_at")
search_fields = ("account", "team")
list_display = (
"account",
"team",
"team_new",
"role",
"role_new",
"level",
"start_at",
"end_at",
)
search_fields = (
"account",
"team",
"team_new",
"role",
"role_new",
)
readonly_fields = ("created_at", "updated_at")
ordering = ["account", "start_at"]

Expand Down Expand Up @@ -336,6 +379,8 @@ def has_delete_permission(self, request, obj=None):


admin.site.register(Account, AccountAdmin)
admin.site.register(Team, TeamAdmin)
admin.site.register(Role, RoleAdmin)
admin.site.register(Career, CareerAdmin)
admin.site.register(Subscription, SubscriptionAdmin)
admin.site.register(BDGroup)
Expand Down
4 changes: 3 additions & 1 deletion backend/apps/account/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ class Migration(migrations.Migration):
),
(
"twitter",
models.CharField(blank=True, max_length=255, null=True, verbose_name="Twitter"),
models.CharField(
blank=True, max_length=255, null=True, verbose_name="Twitter"
),
),
(
"linkedin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Generated by Django 4.2.18 on 2025-02-04 04:02

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("account", "0018_account_gcp_email"),
]

operations = [
migrations.CreateModel(
name="Role",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("slug", models.SlugField(unique=True)),
("name", models.CharField(max_length=100, unique=True, verbose_name="Name")),
(
"description",
models.TextField(blank=True, null=True, verbose_name="Description"),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Role",
"verbose_name_plural": "Roles",
"ordering": ["name"],
},
),
migrations.CreateModel(
name="Team",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("slug", models.SlugField(unique=True)),
("name", models.CharField(max_length=100, unique=True, verbose_name="Name")),
(
"description",
models.TextField(blank=True, null=True, verbose_name="Description"),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Team",
"verbose_name_plural": "Teams",
"ordering": ["name"],
},
),
migrations.AlterField(
model_name="career",
name="end_at",
field=models.DateField(blank=True, null=True, verbose_name="End at"),
),
migrations.AlterField(
model_name="career",
name="level",
field=models.CharField(blank=True, max_length=40, verbose_name="Level"),
),
migrations.AlterField(
model_name="career",
name="role",
field=models.CharField(blank=True, max_length=40, verbose_name="Role"),
),
migrations.AlterField(
model_name="career",
name="start_at",
field=models.DateField(blank=True, null=True, verbose_name="Start at"),
),
migrations.AddField(
model_name="career",
name="team_new",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="careers",
to="account.team",
),
),
]
24 changes: 24 additions & 0 deletions backend/apps/account/migrations/0020_career_role_new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.18 on 2025-02-04 04:04

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("account", "0019_role_team_alter_career_end_at_alter_career_level_and_more"),
]

operations = [
migrations.AddField(
model_name="career",
name="role_new",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="careers",
to="account.role",
),
),
]
55 changes: 46 additions & 9 deletions backend/apps/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ class Account(BaseModel, AbstractBaseUser, PermissionsMixin):
uuid = models.UUIDField(primary_key=False, default=uuid4)

email = models.EmailField("Email", unique=True)
gcp_email = models.EmailField("GCP email", null=True, blank=True) # Google Cloud Platform email
gcp_email = models.EmailField(
"GCP email", null=True, blank=True
) # Google Cloud Platform email
username = models.CharField("Username", max_length=40, blank=True, null=True, unique=True)

first_name = models.CharField("Nome", max_length=40, blank=True)
Expand Down Expand Up @@ -451,17 +453,52 @@ def delete(self):
self.save()


class Team(BaseModel):
slug = models.SlugField(unique=True)
name = models.CharField("Name", max_length=100, unique=True)
description = models.TextField("Description", null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
verbose_name = "Team"
verbose_name_plural = "Teams"
ordering = ["name"]

def __str__(self):
return self.name


class Role(BaseModel):
slug = models.SlugField(unique=True)
name = models.CharField("Name", max_length=100, unique=True)
description = models.TextField("Description", null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
verbose_name = "Role"
verbose_name_plural = "Roles"
ordering = ["name"]

def __str__(self):
return self.name


class Career(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid4)
account = models.ForeignKey(Account, on_delete=models.DO_NOTHING, related_name="careers")

team = models.CharField("Equipe", max_length=40, blank=True)
role = models.CharField("Cargo", max_length=40, blank=True)
level = models.CharField("Nível", max_length=40, blank=True)

start_at = models.DateField("Data de Início", null=True, blank=True)
end_at = models.DateField("Data de Término", null=True, blank=True)

team_new = models.ForeignKey(
Team, on_delete=models.DO_NOTHING, related_name="careers", null=True, blank=True
)
role = models.CharField("Role", max_length=40, blank=True)
role_new = models.ForeignKey(
Role, on_delete=models.DO_NOTHING, related_name="careers", null=True, blank=True
)
level = models.CharField("Level", max_length=40, blank=True)
start_at = models.DateField("Start at", null=True, blank=True)
end_at = models.DateField("End at", null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand All @@ -475,7 +512,7 @@ def __str__(self):
def get_team(self):
return self.team

get_team.short_description = "Equipe"
get_team.short_description = "Team"


class Subscription(BaseModel):
Expand Down
12 changes: 11 additions & 1 deletion backend/apps/account/translation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# -*- coding: utf-8 -*-
from modeltranslation.translator import TranslationOptions, translator

from .models import Account
from .models import Account, Team, Role


class TeamTranslationOptions(TranslationOptions):
fields = ("name", "description")


class RoleTranslationOptions(TranslationOptions):
fields = ("name", "description")


class AccountTranslationOptions(TranslationOptions):
fields = ("description",)


translator.register(Account, AccountTranslationOptions)
translator.register(Team, TeamTranslationOptions)
translator.register(Role, RoleTranslationOptions)
3 changes: 2 additions & 1 deletion backend/apps/account_payment/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def setup_intent_succeeded(event: Event, **kwargs):
return logger.info(f"Ignore setup intent from {backend_url}")

StripeCustomer.modify(
customer.id, invoice_settings={"default_payment_method": setup_intent.get("payment_method")}
customer.id,
invoice_settings={"default_payment_method": setup_intent.get("payment_method")},
)

subscriptions = StripeSubscription.list(customer=customer.id)
Expand Down
Loading
Loading