return slug in next/prev calculation
This commit is contained in:
@@ -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())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user