Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Martín Miranda
/
capacitacion_django
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Martín Miranda
2021-09-29 10:08:39 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
33cfead8aec78c44a152ec08bf5f8f2e855e4abc
33cfead8
1 parent
289992ba
Arregla TipoOrganismoAdmin
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
7 deletions
capacitacion/settings.py
organismo/admin.py
organismo/migrations/0004_alter_organismo_tipo.py
requirements/base.py → requirements/base.txt
requirements/development.txt
capacitacion/settings.py
View file @
33cfead
...
...
@@ -37,9 +37,14 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
# Aplicaciones de tercero
'django_extensions'
,
# Aplicaciones propias
'persona'
,
'organismo'
,
'core'
,
]
MIDDLEWARE
=
[
...
...
organismo/admin.py
View file @
33cfead
...
...
@@ -3,17 +3,18 @@ from django.db.models import Count
from
organismo.models
import
Organismo
,
TipoOrganismo
@admin.register
(
TipoOrganismo
)
class
TipoOrganismoAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'nombre'
,
'es_activo'
,
'cantidad_organismo'
)
search_fields
=
(
'nombre'
,)
actions
=
(
'desactivar_seleccionados'
,
)
actions
=
(
'desactivar_seleccionados'
,
)
def
get_queryset
(
self
,
request
):
queryset
=
super
()
.
get_queryset
(
request
)
.
values
(
'organismos'
)
.
annotate
(
cantidad_organismo
=
Count
(
'organismos'
))
.
all
(
)
queryset
=
super
()
.
get_queryset
(
request
)
.
annotate
(
cantidad_organismo
=
Count
(
'organismos'
)
)
if
request
.
user
.
is_superuser
:
return
queryset
return
queryset
.
filter
(
es_activo
=
True
)
def
desactivar_seleccionados
(
self
,
request
,
queryset
):
...
...
@@ -21,12 +22,10 @@ class TipoOrganismoAdmin(admin.ModelAdmin):
def
cantidad_organismo
(
self
,
tipo
):
return
tipo
.
cantidad_organismo
@admin.register
(
Organismo
)
class
OrganismoAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'nombre'
,
'tipo'
)
search_fields
=
(
'nombre'
,
'tipo__nombre'
)
autocomplete_fields
=
(
'tipo'
,)
\ No newline at end of file
autocomplete_fields
=
(
'tipo'
,)
...
...
organismo/migrations/0004_alter_organismo_tipo.py
0 → 100644
View file @
33cfead
# Generated by Django 3.2.7 on 2021-09-29 12:56
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'organismo'
,
'0003_tipoorganismo_es_activo'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'organismo'
,
name
=
'tipo'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'organismos'
,
to
=
'organismo.tipoorganismo'
),
),
]
...
...
requirements/base.
py
→ requirements/base.
txt
View file @
33cfead
django
==
3.2
.
7
\ No newline at end of file
django==3.2.7
...
...
requirements/development.txt
0 → 100644
View file @
33cfead
-r base.txt
django-extensions==3.1.3
\ No newline at end of file
...
...
Please
register
or
login
to post a comment