Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
a271f88d
Commit
a271f88d
authored
1 year ago
by
kelly.nguyen
Browse files
Options
Downloads
Patches
Plain Diff
deleteAssignment with ID from BDD
parent
f29e8883
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#32258
passed
1 year ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/managers/GitlabManager.ts
+4
-5
4 additions, 5 deletions
ExpressAPI/src/managers/GitlabManager.ts
ExpressAPI/src/routes/AssignmentRoutes.ts
+25
-7
25 additions, 7 deletions
ExpressAPI/src/routes/AssignmentRoutes.ts
with
29 additions
and
12 deletions
ExpressAPI/src/managers/GitlabManager.ts
+
4
−
5
View file @
a271f88d
...
@@ -274,11 +274,10 @@ class GitlabManager {
...
@@ -274,11 +274,10 @@ class GitlabManager {
}
}
async
moveRepositorySubGroup
(
repoId
:
number
,
newRepoId
:
number
)
{
async
moveRepositorySubGroup
(
repoId
:
number
,
newRepoId
:
number
)
{
const
response
=
await
axios
.
put
(
this
.
getApiUrl
(
GitlabRoute
.
REPOSITORY_MOVE_SUBGROUP
).
replace
(
'
{{id}}
'
,
String
(
repoId
)),
{
const
response
=
await
axios
.
put
(
this
.
getApiUrl
(
GitlabRoute
.
REPOSITORY_MOVE_SUBGROUP
).
replace
(
'
{{id}}
'
,
String
(
repoId
)),
namespace
:
newRepoId
{
}
namespace
:
newRepoId
);
});
return
response
.
data
;
return
response
.
data
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/routes/AssignmentRoutes.ts
+
25
−
7
View file @
a271f88d
...
@@ -50,8 +50,8 @@ class AssignmentRoutes implements RoutesManager {
...
@@ -50,8 +50,8 @@ class AssignmentRoutes implements RoutesManager {
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/publish
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
publishAssignment
.
bind
(
this
));
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/publish
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
publishAssignment
.
bind
(
this
));
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/unpublish
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
unpublishAssignment
.
bind
(
this
));
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/unpublish
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
unpublishAssignment
.
bind
(
this
));
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/deleted
'
,
SecurityMiddleware
.
check
(
fals
e
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
deleteAssignment
.
bind
(
this
));
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/deleted
'
,
SecurityMiddleware
.
check
(
tru
e
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
deleteAssignment
.
bind
(
this
));
}
}
// Get an assignment by its name or gitlab url
// Get an assignment by its name or gitlab url
private
async
getAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
private
async
getAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
...
@@ -215,19 +215,37 @@ class AssignmentRoutes implements RoutesManager {
...
@@ -215,19 +215,37 @@ class AssignmentRoutes implements RoutesManager {
private
async
deleteAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
private
async
deleteAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
const
nameAssignment
=
req
.
params
.
assignmentNameOrUrl
;
const
nameAssignment
=
req
.
params
.
assignmentNameOrUrl
;
// recup l'id du repo en question
const
repo
=
await
db
.
assignment
.
findUnique
({
await
GitlabManager
.
removeRepositoryMember
(
13893
,
627
);
where
:
{
await
GitlabManager
.
moveRepositorySubGroup
(
13893
,
14193
);
name
:
String
(
nameAssignment
)
}
});
if
(
!
repo
)
{
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
NOT_FOUND
);
}
const
members
=
await
GitlabManager
.
getRepositoryMembers
(
String
(
repo
[
'
gitlabId
'
]));
members
.
forEach
(
async
member
=>
{
if
(
member
.
id
!==
Config
.
gitlab
.
account
.
id
)
{
await
GitlabManager
.
removeRepositoryMember
(
repo
[
'
gitlabId
'
],
member
.
id
);
}
});
await
GitlabManager
.
moveRepositorySubGroup
(
repo
[
'
gitlabId
'
],
14193
);
// recup l'id du repo en question
await
GitlabManager
.
removeRepositoryMember
(
repo
[
'
gitlabId
'
],
627
);
await
db
.
assignment
.
update
({
await
db
.
assignment
.
update
({
where
:
{
where
:
{
name
:
nameAssignment
name
:
String
(
nameAssignment
)
},
},
data
:
{
data
:
{
deleted
:
true
deleted
:
true
}
}
});
});
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
);
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
);
}
}
}
}
...
...
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