event's API support update and image_url

This commit is contained in:
les
2020-05-14 22:36:58 +02:00
parent 34395c3d66
commit 22381d1fe6
7 changed files with 300 additions and 232 deletions

View File

@@ -236,6 +236,8 @@ const eventController = {
if (req.file) {
eventDetails.image_path = req.file.filename
} else if (body.image_url) {
eventDetails.image_path = await helpers.getImageFromURL(body.image_url)
}
const event = await Event.create(eventDetails)
@@ -289,6 +291,7 @@ const eventController = {
}
const body = req.body
const event = await Event.findByPk(body.id)
if (!event) return res.sendStatus(404)
if (!req.user.is_admin && event.userId !== req.user.id) {
return res.sendStatus(403)
}
@@ -316,6 +319,8 @@ const eventController = {
}
}
eventDetails.image_path = req.file.filename
} else if (body.image_url) {
eventDetails.image_path = await helpers.getImageFromURL(body.image_url)
}
await event.update(eventDetails)