Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ELC_elections
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
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gestion-des-assemblees
ELC_elections
Commits
1a80ce45
Commit
1a80ce45
authored
4 years ago
by
Alexis POYEN
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Update role should remove capturer"
parent
8951cf80
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
internal/models/capturer.go
+1
-1
1 addition, 1 deletion
internal/models/capturer.go
web/components/users/handleUser.js
+11
-4
11 additions, 4 deletions
web/components/users/handleUser.js
web/services/model/capturer-model.js
+4
-4
4 additions, 4 deletions
web/services/model/capturer-model.js
with
16 additions
and
9 deletions
internal/models/capturer.go
+
1
−
1
View file @
1a80ce45
...
...
@@ -137,7 +137,7 @@ func (d *DataHandler) deleteCapturerAdmin(w http.ResponseWriter, r *http.Request
http
.
Error
(
w
,
ErrorIDIsMissing
,
http
.
StatusNotFound
)
return
}
d
.
db
.
Delete
(
&
o
)
d
.
db
.
Unscoped
()
.
Delete
(
&
o
)
}
else
{
http
.
Error
(
w
,
ErrorIDIsMissing
,
http
.
StatusNotFound
)
}
...
...
This diff is collapsed.
Click to expand it.
web/components/users/handleUser.js
+
11
−
4
View file @
1a80ce45
...
...
@@ -226,6 +226,11 @@ class HandleUser {
let
user
=
await
response
.
json
();
if
(
user
!=
undefined
&&
user
.
role
==
"
CAPTURER
"
)
await
this
.
postCapturer
(
user
,
method
);
else
if
(
user
.
role
!=
"
CAPTURER
"
)
{
let
capturer
=
await
Auth
.
getCapturerByUserID
(
user
.
id
,
current_user
);
if
(
capturer
!=
undefined
)
await
this
.
CapturerModel
.
deleteCapturer
(
capturer
.
ID
);
}
this
.
parent
.
displayUsers
();
}
catch
(
e
)
{
Messages
.
Show
(
"
is-warning
"
,
e
.
message
);
...
...
@@ -236,9 +241,11 @@ class HandleUser {
async
postCapturer
(
user
,
method
)
{
let
capturer
;
if
(
method
===
"
PUT
"
)
capturer
=
await
Auth
.
getCapturerByUserID
(
user
.
id
,
current_user
);
else
capturer
=
{};
this
.
CapturerModel
.
saveCapturer
(
method
,
capturer
.
ID
,
user
.
ID
,
user
.
name
);
capturer
=
await
Auth
.
getCapturerByUserID
(
user
.
id
,
current_user
);
if
(
capturer
==
undefined
)
{
capturer
=
{
ID
:
0
};
method
=
"
POST
"
;
}
this
.
CapturerModel
.
saveCapturer
(
method
,
capturer
.
ID
,
user
.
id
,
user
.
name
);
}
}
This diff is collapsed.
Click to expand it.
web/services/model/capturer-model.js
+
4
−
4
View file @
1a80ce45
...
...
@@ -55,10 +55,10 @@ class CapturerModel {
async
saveCapturer
(
method
,
ID
,
UserID
,
Name
)
{
try
{
const
response
=
await
fetch
(
"
/api/Capturer/
"
+
capturer
.
ID
,
{
const
response
=
await
fetch
(
"
/api/Capturer/
"
+
ID
,
{
method
:
method
,
headers
:
new
Headers
({
"
XSRF-Token
"
:
current_user
.
xsrftoken
,
"
XSRF-Token
"
:
this
.
current_user
.
xsrftoken
,
}),
body
:
JSON
.
stringify
({
ID
:
ID
,
...
...
@@ -68,11 +68,10 @@ class CapturerModel {
});
if
(
response
.
status
!==
200
)
{
throw
new
Error
(
`Capturer could not be
delet
ed (status
${
response
.
status
}
)`
`Capturer could not be
sav
ed (status
${
response
.
status
}
)`
);
}
this
.
refreshCapturers
();
Messages
.
Show
(
"
is-success
"
,
"
Bureau de vote mis à jour
"
);
return
await
response
.
json
();
}
catch
(
e
)
{
Messages
.
Show
(
"
is-warning
"
,
e
.
message
);
...
...
@@ -94,6 +93,7 @@ class CapturerModel {
`Capturer could not be deleted (status
${
response
.
status
}
)`
);
}
this
.
refreshCapturers
();
}
catch
(
e
)
{
Messages
.
Show
(
"
is-warning
"
,
e
.
message
);
console
.
error
(
e
);
...
...
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