Skip to content

Commit

Permalink
🔧 Classe Pessoa refatorada
Browse files Browse the repository at this point in the history
  • Loading branch information
GomesMilla committed Jul 19, 2021
1 parent ac5b868 commit 0dfb676
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 14 additions & 3 deletions Usuarios/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
from django.contrib import admin
from Usuarios.models import *

# Sobrescrevendo a classe admin padrão!

class PessoaAdmin(admin.ModelAdmin):
list_display = ('Nome', 'Email', 'Cpf','estado')
list_filter = ('is_active','is_superuser','is_staff')
list_display = ('Nome', 'Email', 'Cpf','estado') #Dentro do admin na class Pessoas, é esses atributos que será mostrado
list_filter = ('is_active','is_superuser','is_staff')#Filtrar Pessoas por esses atributos
date_hierarchy = 'DataCadastro'
readonly_fields = ('DataCadastro','Nascimento','Cpf')
readonly_fields = ('DataCadastro','Nascimento','Cpf')#Altera aqueles campos, deixando somente para leitura
search_fields = ['Nome']#Campo de pesquisa por nome
view_on_site = False


# class GerenteAdmin(admin.ModelAdmin):
# list_display = ('Nome', 'Email', 'Cpf','estado')
# list_filter = ('is_active','is_superuser','is_staff')
# date_hierarchy = 'DataCadastro'
# readonly_fields = ('DataCadastro','Nascimento','Cpf')

admin.site.register(Pessoa,PessoaAdmin)
# admin.site.register(Gerente)
Expand Down
18 changes: 9 additions & 9 deletions Usuarios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ def __str__(self):



# class Gerente(models.Model):
# pessoa = models.ForeignKey(Pessoa, on_delete=models.CASCADE)
class Gerente(models.Model):
pessoa = models.ForeignKey(Pessoa, on_delete=models.CASCADE)

# class Meta:
# verbose_name = "Gerente"
# verbose_name_plural = "Gerentes"
# ordering = ['pessoa']
# db_table = "Gerente"
class Meta:
verbose_name = "Gerente"
verbose_name_plural = "Gerentes"
ordering = ['pessoa']
db_table = "Gerente"

# def __str__(self):
# return self.pessoa.nome
def __str__(self):
return self.pessoa.nome


# class Empresa(models.Model):
Expand Down

0 comments on commit 0dfb676

Please sign in to comment.