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
088ca8cd
Commit
088ca8cd
authored
Feb 07, 2020
by
Enrique Matías Sánchez (Quique)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat Permitir editar cualquier proyecto a los gestores.
Incluso si está presentado.
parent
0f42129c
Pipeline
#527
failed with stage
in 1 second
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
4 deletions
+73
-4
0006_auto_20200207_0919.py
indo/migrations/0006_auto_20200207_0919.py
+58
-0
models.py
indo/models.py
+4
-0
views.py
indo/views.py
+10
-3
detail.html
templates/proyecto/detail.html
+1
-1
No files found.
indo/migrations/0006_auto_20200207_0919.py
0 → 100644
View file @
088ca8cd
# Generated by Django 3.0.2 on 2020-02-07 08:19
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
=
"editar_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"
,
"0005_auto_20200203_1316"
)]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
"proyecto"
,
options
=
{
"permissions"
:
[
(
"listar_proyectos"
,
"Puede ver el listado de todos los proyectos."
,
),
(
"ver_proyecto"
,
"Puede ver cualquier proyecto."
),
(
"editar_proyecto"
,
"Puede editar cualquier proyecto en cualquier momento."
,
),
]
},
),
migrations
.
RunPython
(
geo_post_migrate_signal
),
migrations
.
RunPython
(
add_permission_to_group
),
]
indo/models.py
View file @
088ca8cd
...
...
@@ -483,6 +483,10 @@ class Proyecto(models.Model):
permissions
=
[
(
"listar_proyectos"
,
_
(
"Puede ver el listado de todos los proyectos."
)),
(
"ver_proyecto"
,
_
(
"Puede ver cualquier proyecto."
)),
(
"editar_proyecto"
,
_
(
"Puede editar cualquier proyecto en cualquier momento."
),
),
]
def
__str__
(
self
):
...
...
indo/views.py
View file @
088ca8cd
...
...
@@ -192,7 +192,9 @@ class InvitacionView(LoginRequiredMixin, ChecksMixin, CreateView):
def
test_func
(
self
):
# TODO: Comprobar estado del proyecto, fecha.
return
self
.
es_coordinador
(
self
.
kwargs
[
"proyecto_id"
])
return
self
.
es_coordinador
(
self
.
kwargs
[
"proyecto_id"
]
)
or
self
.
request
.
user
.
has_perm
(
"indo.editar_proyecto"
)
class
ParticipanteAceptarView
(
LoginRequiredMixin
,
RedirectView
):
...
...
@@ -298,7 +300,9 @@ class ParticipanteDeleteView(LoginRequiredMixin, ChecksMixin, DeleteView):
return
reverse_lazy
(
"proyecto_detail"
,
args
=
[
self
.
object
.
proyecto
.
id
])
def
test_func
(
self
):
return
self
.
es_coordinador
(
self
.
get_object
()
.
proyecto
.
id
)
return
self
.
es_coordinador
(
self
.
get_object
()
.
proyecto
.
id
)
or
self
.
request
.
user
.
has_perm
(
"indo.editar_proyecto"
)
class
ProyectoCreateView
(
LoginRequiredMixin
,
ChecksMixin
,
CreateView
):
...
...
@@ -406,7 +410,9 @@ class ProyectoDetailView(LoginRequiredMixin, ChecksMixin, DetailView):
context
[
"permitir_edicion"
]
=
(
self
.
es_coordinador
(
self
.
object
.
id
)
and
self
.
object
.
en_borrador
()
)
)
or
self
.
request
.
user
.
has_perm
(
"indo.editar_proyecto"
)
context
[
"es_editor"
]
=
self
.
request
.
user
.
has_perm
(
"indo.editar_proyecto"
)
return
context
...
...
@@ -692,6 +698,7 @@ class ProyectoUpdateFieldView(LoginRequiredMixin, ChecksMixin, UpdateView):
self
.
kwargs
[
"campo"
]
==
"visto_bueno_estudio"
and
self
.
es_coordinador_estudio
(
self
.
kwargs
[
"pk"
])
)
or
self
.
request
.
user
.
has_perm
(
"indo.editar_proyecto"
)
)
...
...
templates/proyecto/detail.html
View file @
088ca8cd
...
...
@@ -216,7 +216,7 @@
<span
class=
"fas fa-step-backward"
></span>
{% trans 'Retroceder' %}
</a>
{% if permitir_edicion %}
{% if permitir_edicion
and not es_editor
%}
<button
class=
"btn btn-danger"
data-toggle=
"modal"
data-target=
"#anularModal"
type=
"button"
>
<span
class=
"fas fa-trash-alt"
></span>
{% trans 'Anular' %}
</button>
...
...
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