Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Easter-eggs
Néobab
Commits
9c2676bc
Commit
9c2676bc
authored
Jun 27, 2022
by
Tanguy Le Carrour
Browse files
Empêche la suppression d'un planning validé (#87469).
parent
6d60088a
Pipeline
#6710
passed with stages
in 17 minutes and 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
neobab/models/entities.py
View file @
9c2676bc
...
...
@@ -1325,11 +1325,13 @@ class FicheUe(Base):
def
supprimer_planning
(
self
,
un_id_planning
):
for
planning
in
self
.
plannings
:
if
planning
.
id
==
un_id_planning
:
if
planning
.
valide_le
:
raise
ValueError
(
"Impossible de supprimer le planning validé !"
)
self
.
plannings
.
remove
(
planning
)
DBSession
.
delete
(
planning
)
self
.
reordonner_plannings
([
p
.
id
for
p
in
self
.
plannings
])
return
raise
ValueError
(
f
"
Unknown planning #
{
un_id_planning
}
!
"
)
raise
ValueError
(
f
"
Planning inconnu ! [id=
{
un_id_planning
}
]
"
)
def
valider_planning
(
self
,
un_planning
):
for
planning
in
self
.
plannings
:
...
...
tests/models/test_entities.py
View file @
9c2676bc
...
...
@@ -479,33 +479,39 @@ class TestFicheUe:
expect
(
fiche
.
plannings
[
2
].
ordre
).
to
.
eq
(
3
)
expect
(
fiche
.
plannings
[
3
].
ordre
).
to
.
eq
(
4
)
# FIXME fail because of the ORM
@
pytest
.
mark
.
skip
(
reason
=
"À corriger !"
)
def
test_supprimer_planning_erreur
(
self
):
with
transaction
.
manager
:
fiche
=
self
.
fiche
()
DBSession
.
add
(
fiche
)
def
test_supprimer_planning_inconnu
(
self
):
fiche
=
self
.
fiche
()
def
action
():
fiche
.
supprimer_planning
(
1
)
def
action
():
fiche
.
supprimer_planning
(
1
)
expect
(
action
).
to
.
throw
(
Exception
)
expect
(
action
).
to
.
throw
(
ValueError
)
# FIXME fail because of the ORM
@
pytest
.
mark
.
skip
(
reason
=
"À corriger !"
)
def
test_supprimer_planning_valide
(
self
):
fiche
=
self
.
fiche
()
planning
=
construire_planning
()
planning
.
id
=
1
planning
.
valider
()
fiche
.
ajouter_planning
(
planning
)
def
action
():
fiche
.
supprimer_planning
(
1
)
expect
(
action
).
to
.
throw
(
ValueError
)
@
pytest
.
mark
.
skip
(
reason
=
"Dépend de l'ORM !?"
)
def
test_supprimer_planning
(
self
):
with
transaction
.
manager
:
fiche
=
self
.
fiche
()
p1
,
p2
,
p3
=
construire_plannings
(
3
)
fiche
.
ajouter_planning
(
p1
)
fiche
.
ajouter_planning
(
p2
)
fiche
.
ajouter_planning
(
p3
)
p2
.
id
=
2
fiche
=
self
.
fiche
()
p1
,
p2
,
p3
=
construire_plannings
(
3
)
fiche
.
ajouter_planning
(
p1
)
fiche
.
ajouter_planning
(
p2
)
fiche
.
ajouter_planning
(
p3
)
p2
.
id
=
2
fiche
.
supprimer_planning
(
p2
.
id
)
fiche
.
supprimer_planning
(
p2
.
id
)
expect
(
fiche
.
plannings
).
to
.
have
.
length
(
2
)
expect
(
p3
.
ordre
).
to
.
eq
(
2
)
expect
(
fiche
.
plannings
).
to
.
have
.
length
(
2
)
expect
(
p3
.
ordre
).
to
.
eq
(
2
)
def
test_reordonner_plannings
(
self
):
fiche
=
self
.
fiche
()
...
...
Write
Preview
Supports
Markdown
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