Skip to content

Commit

Permalink
Merge pull request #744 from basedosdados/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rdahis authored Feb 4, 2025
2 parents bb63ae4 + fcd2ecb commit acb4b35
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 13 deletions.
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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'),
),
]
19 changes: 19 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,19 @@
# 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'),
),
]
46 changes: 38 additions & 8 deletions backend/apps/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,47 @@ 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 +505,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
9 changes: 8 additions & 1 deletion backend/apps/account/translation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# -*- 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)
1 change: 1 addition & 0 deletions backend/apps/api/v1/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ class RawDataSourceAdmin(OrderedInlineModelAdminMixin, TabbedTranslationAdmin):
]
inlines = [
CoverageInline,
UpdateInline,
ObservationLevelInline,
PollInline,
]
Expand Down
17 changes: 17 additions & 0 deletions backend/apps/api/v1/migrations/0053_rename_required_requires.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.10 on 2025-02-04

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
('v1', '0052_remove_dataset_is_closed'),
]

operations = [
migrations.RenameField(
model_name='rawdatasource',
old_name='required_registration',
new_name='requires_registration',
),
]
2 changes: 1 addition & 1 deletion backend/apps/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ class RawDataSource(BaseModel, OrderedModel):
contains_structured_data = models.BooleanField(default=False)
contains_api = models.BooleanField(default=False)
is_free = models.BooleanField(default=False)
required_registration = models.BooleanField(default=False)
requires_registration = models.BooleanField(default=False)
version = models.IntegerField(null=True, blank=True)
status = models.ForeignKey(
"Status",
Expand Down

0 comments on commit acb4b35

Please sign in to comment.