Rename awtis to artistes
This commit is contained in:
+10
-10
@@ -8,13 +8,13 @@
|
||||
const slugify = require('slugify')
|
||||
|
||||
const jwennTeksEpiId = async data => {
|
||||
const teks = await strapi.query('teks').find({id_in: data})
|
||||
const teks = await strapi.query('paroles').find({id_in: data})
|
||||
return teks
|
||||
}
|
||||
|
||||
const jwennAwtisEpiId = async id => {
|
||||
const awtis = await strapi.query('awtis').find({id})
|
||||
return awtis
|
||||
const artiste = await strapi.query('artiste').find({id})
|
||||
return artiste
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@@ -33,16 +33,16 @@ module.exports = {
|
||||
afterUpdate: async event => {
|
||||
let {data} = event
|
||||
const {id} = data
|
||||
const awtis = await jwennAwtisEpiId(id)
|
||||
const artiste = await jwennAwtisEpiId(id)
|
||||
|
||||
if (awtis.teks && awtis.teks.length >= 1) {
|
||||
const teks = await jwennTeksEpiId(awtis.teks)
|
||||
Promise.all(teks.map(async t => {
|
||||
const {id, tit, slug, awtis} = t
|
||||
const alias = awtis.map(a => a.alias).join('-')
|
||||
if (artiste.teks && artiste.paroles.length >= 1) {
|
||||
const paroles = await jwennTeksEpiId(artiste.paroles)
|
||||
Promise.all(paroles.map(async t => {
|
||||
const {id, tit, slug, artiste} = t
|
||||
const alias = artiste.map(a => a.alias).join('-')
|
||||
const slugUpdated = slugify(`${alias}-${tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||
if (slug !== slugUpdated) {
|
||||
await strapi.query('teks').update(
|
||||
await strapi.query('paroles').update(
|
||||
{id},
|
||||
{slug: slugUpdated}
|
||||
)
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"kind": "collectionType",
|
||||
"collectionName": "awtis",
|
||||
"collectionName": "artistes",
|
||||
"info": {
|
||||
"singularName": "awti",
|
||||
"pluralName": "awtis",
|
||||
"displayName": "Awtis",
|
||||
"singularName": "artiste",
|
||||
"pluralName": "artistes",
|
||||
"displayName": "Artistes",
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
@@ -30,11 +30,11 @@
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"teks": {
|
||||
"paroles": {
|
||||
"type": "relation",
|
||||
"relation": "manyToMany",
|
||||
"target": "api::tek.tek",
|
||||
"inversedBy": "awtis"
|
||||
"target": "api::parole.parole",
|
||||
"inversedBy": "artistes"
|
||||
},
|
||||
"admin_user": {
|
||||
"type": "relation",
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
const { createCoreController } = require('@strapi/strapi').factories;
|
||||
|
||||
module.exports = createCoreController('api::awti.awti')
|
||||
module.exports = createCoreController('api::artiste.artiste')
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
const { createCoreRouter } = require('@strapi/strapi').factories;
|
||||
|
||||
module.exports = createCoreRouter('api::awti.awti')
|
||||
module.exports = createCoreRouter('api::artiste.artiste')
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
const { createCoreService } = require('@strapi/strapi').factories;
|
||||
|
||||
module.exports = createCoreService('api::awti.awti');
|
||||
module.exports = createCoreService('api::artiste.artiste');
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user