Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
manhattan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
InnovacionDocente
manhattan
Commits
97893c58
Commit
97893c58
authored
Jan 31, 2020
by
Enrique Matías Sánchez (Quique)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dar permiso a los gestores para ver cualquier proyecto
parent
79d55100
Pipeline
#519
failed with stage
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
6 deletions
+86
-6
0003_auto_20200131_1245.py
indo/migrations/0003_auto_20200131_1245.py
+25
-2
0004_auto_20200131_1409.py
indo/migrations/0004_auto_20200131_1409.py
+54
-0
models.py
indo/models.py
+2
-1
views.py
indo/views.py
+5
-3
No files found.
indo/migrations/0003_auto_20200131_1245.py
View file @
97893c58
# Generated by Django 3.0.2 on 2020-01-31 11:45
# https://docs.djangoproject.com/en/3.0/howto/writing-migrations/
from
django.db
import
migrations
from
django.apps
import
apps
as
django_apps
from
django.db
import
migrations
,
models
def
add_managers_group
(
apps
,
schema_editor
):
...
...
@@ -15,8 +16,30 @@ def add_managers_group(apps, schema_editor):
group
.
permissions
.
add
(
listar_proyectos
)
def
geo_post_migrate_signal
(
apps
,
schema_editor
):
"""Emit the post-migrate signal during the migration.
Permissions are not actually created during or after an individual migration,
but are triggered by a post-migrate signal which is sent after the
`python manage.py migrate` command completes successfully.
This is necessary because this permission is used in the next migration.
"""
indo_config
=
django_apps
.
get_app_config
(
"indo"
)
models
.
signals
.
post_migrate
.
send
(
sender
=
indo_config
,
app_config
=
indo_config
,
verbosity
=
2
,
interactive
=
False
,
using
=
schema_editor
.
connection
.
alias
,
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[(
"indo"
,
"0002_auto_20200131_1244"
)]
operations
=
[
migrations
.
RunPython
(
add_managers_group
)]
operations
=
[
migrations
.
RunPython
(
add_managers_group
),
migrations
.
RunPython
(
geo_post_migrate_signal
),
]
indo/migrations/0004_auto_20200131_1409.py
0 → 100644
View file @
97893c58
# Generated by Django 3.0.2 on 2020-01-31 13:09
from
django.apps
import
apps
as
django_apps
from
django.db
import
migrations
,
models
def
add_permission_to_group
(
apps
,
schema_editor
):
group
=
apps
.
get_model
(
"auth"
,
"Group"
)
permission
=
apps
.
get_model
(
"auth"
,
"Permission"
)
gestores
=
group
.
objects
.
get
(
name
=
"Gestores"
)
ver_proyecto
=
permission
.
objects
.
get
(
codename
=
"ver_proyecto"
)
gestores
.
permissions
.
add
(
ver_proyecto
)
def
geo_post_migrate_signal
(
apps
,
schema_editor
):
"""Emit the post-migrate signal during the migration.
Permissions are not actually created during or after an individual migration,
but are triggered by a post-migrate signal which is sent after the
`python manage.py migrate` command completes successfully.
This is necessary because this permission is used later in this migration.
"""
indo_config
=
django_apps
.
get_app_config
(
"indo"
)
models
.
signals
.
post_migrate
.
send
(
sender
=
indo_config
,
app_config
=
indo_config
,
verbosity
=
2
,
interactive
=
False
,
using
=
schema_editor
.
connection
.
alias
,
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[(
"indo"
,
"0003_auto_20200131_1245"
)]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
"proyecto"
,
options
=
{
"permissions"
:
[
(
"listar_proyectos"
,
"Puede ver el listado de todos los proyectos presentados."
,
),
(
"ver_proyecto"
,
"Puede ver cualquier proyecto."
),
]
},
),
migrations
.
RunPython
(
geo_post_migrate_signal
),
migrations
.
RunPython
(
add_permission_to_group
),
]
indo/models.py
View file @
97893c58
...
...
@@ -474,7 +474,8 @@ class Proyecto(models.Model):
class
Meta
:
permissions
=
[
(
"listar_proyectos"
,
_
(
"Puede ver el listado de todos los proyectos."
))
(
"listar_proyectos"
,
_
(
"Puede ver el listado de todos los proyectos."
)),
(
"ver_proyecto"
,
_
(
"Puede ver cualquier proyecto."
)),
]
def
__str__
(
self
):
...
...
indo/views.py
View file @
97893c58
...
...
@@ -118,8 +118,11 @@ class ChecksMixin(UserPassesTestMixin):
"""
Devuelve si el usuario actual está vinculado al proyecto indicado
o es decano o director del centro del proyecto."""
esta_autorizado
=
self
.
esta_vinculado
(
proyecto_id
)
or
self
.
es_decano_o_director
(
proyecto_id
usuario_actual
=
self
.
request
.
user
esta_autorizado
=
(
self
.
esta_vinculado
(
proyecto_id
)
or
self
.
es_decano_o_director
(
proyecto_id
)
or
usuario_actual
.
has_perm
(
"indo.ver_proyecto"
)
# Gestores y evaluadores
)
self
.
permission_denied_message
=
_
(
"Usted no está vinculado a este proyecto, "
...
...
@@ -382,7 +385,6 @@ class ProyectoDetailView(LoginRequiredMixin, ChecksMixin, DetailView):
return
context
def
test_func
(
self
):
# TODO: Los evaluadores y gestores también tendrán que tener acceso.
proyecto_id
=
self
.
kwargs
[
"pk"
]
return
self
.
esta_vinculado_o_es_decano
(
proyecto_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment