mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
return slug in next/prev calculation
This commit is contained in:
parent
691684d9dc
commit
1ccf0397c5
1 changed files with 6 additions and 6 deletions
|
@ -128,7 +128,7 @@ const eventController = {
|
||||||
|
|
||||||
// get prev and next event
|
// get prev and next event
|
||||||
const next = await Event.findOne({
|
const next = await Event.findOne({
|
||||||
attributes: ['id'],
|
attributes: ['id', 'slug'],
|
||||||
where: {
|
where: {
|
||||||
is_visible: true,
|
is_visible: true,
|
||||||
recurrent: null,
|
recurrent: null,
|
||||||
|
@ -138,7 +138,7 @@ const eventController = {
|
||||||
})
|
})
|
||||||
|
|
||||||
const prev = await Event.findOne({
|
const prev = await Event.findOne({
|
||||||
attributes: ['id'],
|
attributes: ['id', 'slug'],
|
||||||
where: {
|
where: {
|
||||||
is_visible: true,
|
is_visible: true,
|
||||||
recurrent: null,
|
recurrent: null,
|
||||||
|
@ -149,8 +149,8 @@ const eventController = {
|
||||||
|
|
||||||
if (event && (event.is_visible || is_admin)) {
|
if (event && (event.is_visible || is_admin)) {
|
||||||
event = event.get()
|
event = event.get()
|
||||||
event.next = next && next.id
|
event.next = next && (next.slug || next.id)
|
||||||
event.prev = prev && prev.id
|
event.prev = prev && (prev.slug || prev.id)
|
||||||
event.tags = event.tags.map(t => t.tag)
|
event.tags = event.tags.map(t => t.tag)
|
||||||
if (format === 'json') {
|
if (format === 'json') {
|
||||||
res.json(event)
|
res.json(event)
|
||||||
|
@ -360,8 +360,8 @@ const eventController = {
|
||||||
const old_path = path.resolve(config.upload_path, event.image_path)
|
const old_path = path.resolve(config.upload_path, event.image_path)
|
||||||
const old_thumb_path = path.resolve(config.upload_path, 'thumb', event.image_path)
|
const old_thumb_path = path.resolve(config.upload_path, 'thumb', event.image_path)
|
||||||
try {
|
try {
|
||||||
await fs.unlinkSync(old_path)
|
fs.unlinkSync(old_path)
|
||||||
await fs.unlinkSync(old_thumb_path)
|
fs.unlinkSync(old_thumb_path)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.info(e.toString())
|
log.info(e.toString())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue