Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
0533ad59
Commit
0533ad59
authored
11 months ago
by
ilona
Browse files
Options
Downloads
Patches
Plain Diff
API: code http 403 et non 401 si permission non accordée.
parent
9302a173
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/api/justificatifs.py
+1
-1
1 addition, 1 deletion
app/api/justificatifs.py
app/api/partitions.py
+12
-12
12 additions, 12 deletions
app/api/partitions.py
with
13 additions
and
13 deletions
app/api/justificatifs.py
+
1
−
1
View file @
0533ad59
...
...
@@ -765,7 +765,7 @@ def justif_export(justif_id: int | None = None, filename: str | None = None):
current_user
.
has_permission
(
Permission
.
AbsJustifView
)
or
justificatif_unique
.
user_id
==
current_user
.
id
):
return
json_error
(
40
1
,
"
non autorisé à voir ce fichier
"
)
return
json_error
(
40
3
,
"
non autorisé à voir ce fichier
"
)
# On récupère l'archive concernée
archive_name
:
str
=
justificatif_unique
.
fichier
...
...
This diff is collapsed.
Click to expand it.
app/api/partitions.py
+
12
−
12
View file @
0533ad59
...
...
@@ -169,7 +169,7 @@ def group_set_etudiant(group_id: int, etudid: int):
if
not
group
.
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
group
.
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
if
etud
.
id
not
in
{
e
.
id
for
e
in
group
.
partition
.
formsemestre
.
etuds
}:
return
json_error
(
404
,
"
etud non inscrit au formsemestre du groupe
"
)
...
...
@@ -202,7 +202,7 @@ def group_remove_etud(group_id: int, etudid: int):
if
not
group
.
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
group
.
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
group
.
remove_etud
(
etud
)
...
...
@@ -232,7 +232,7 @@ def partition_remove_etud(partition_id: int, etudid: int):
if
not
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
db
.
session
.
execute
(
sa
.
text
(
"""
DELETE FROM group_membership
...
...
@@ -289,7 +289,7 @@ def group_create(partition_id: int): # partition-group-create
if
not
partition
.
groups_editable
:
return
json_error
(
403
,
"
partition non editable
"
)
if
not
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
args
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
group_name
=
args
.
get
(
"
group_name
"
)
...
...
@@ -337,7 +337,7 @@ def group_delete(group_id: int):
if
not
group
.
partition
.
groups_editable
:
return
json_error
(
403
,
"
partition non editable
"
)
if
not
group
.
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
formsemestre_id
=
group
.
partition
.
formsemestre_id
log
(
f
"
deleting
{
group
}
"
)
db
.
session
.
delete
(
group
)
...
...
@@ -378,7 +378,7 @@ def group_edit(group_id: int):
if
not
group
.
partition
.
groups_editable
:
return
json_error
(
403
,
"
partition non editable
"
)
if
not
group
.
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
args
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
if
"
group_name
"
in
args
:
...
...
@@ -423,7 +423,7 @@ def group_set_edt_id(group_id: int, edt_id: str):
)
group
:
GroupDescr
=
query
.
first_or_404
()
if
not
group
.
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
log
(
f
"
group_set_edt_id(
{
group_id
}
,
'
{
edt_id
}
'
)
"
)
group
.
edt_id
=
edt_id
db
.
session
.
add
(
group
)
...
...
@@ -461,7 +461,7 @@ def partition_create(formsemestre_id: int):
if
not
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
data
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
partition_name
=
data
.
get
(
"
partition_name
"
)
if
partition_name
is
None
:
...
...
@@ -523,7 +523,7 @@ def formsemestre_set_partitions_order(formsemestre_id: int):
if
not
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
partition_ids
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
if
not
isinstance
(
partition_ids
,
list
)
and
not
all
(
isinstance
(
x
,
int
)
for
x
in
partition_ids
...
...
@@ -569,7 +569,7 @@ def partition_order_groups(partition_id: int):
if
not
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
group_ids
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
if
not
isinstance
(
group_ids
,
list
)
and
not
all
(
isinstance
(
x
,
int
)
for
x
in
group_ids
...
...
@@ -623,7 +623,7 @@ def partition_edit(partition_id: int):
if
not
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
data
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
modified
=
False
partition_name
=
data
.
get
(
"
partition_name
"
)
...
...
@@ -689,7 +689,7 @@ def partition_delete(partition_id: int):
if
not
partition
.
formsemestre
.
etat
:
return
json_error
(
403
,
"
formsemestre verrouillé
"
)
if
not
partition
.
formsemestre
.
can_change_groups
():
return
json_error
(
40
1
,
"
opération non autorisée
"
)
return
json_error
(
40
3
,
"
opération non autorisée
"
)
if
not
partition
.
partition_name
:
return
json_error
(
API_CLIENT_ERROR
,
"
ne peut pas supprimer la partition par défaut
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment