From 022b18c0f776d60070068a103bda2b533cea4a12 Mon Sep 17 00:00:00 2001 From: julien vdb Date: Fri, 25 Apr 2025 14:32:29 +0200 Subject: [PATCH] Add announcement --- config/plugins.ts | 6 ++ .../content-types/announcement/schema.json | 34 +++++++ .../announcement/controllers/announcement.ts | 7 ++ src/api/announcement/routes/announcement.ts | 7 ++ src/api/announcement/services/announcement.ts | 7 ++ .../choral/content-types/choral/schema.json | 6 ++ .../content-types/event-other/schema.json | 42 +++++++++ .../event-other/controllers/event-other.ts | 7 ++ src/api/event-other/routes/event-other.ts | 7 ++ src/api/event-other/services/event-other.ts | 7 ++ .../content-types/user/schema.json | 6 ++ types/generated/contentTypes.d.ts | 91 +++++++++++++++++++ 12 files changed, 227 insertions(+) create mode 100644 src/api/announcement/content-types/announcement/schema.json create mode 100644 src/api/announcement/controllers/announcement.ts create mode 100644 src/api/announcement/routes/announcement.ts create mode 100644 src/api/announcement/services/announcement.ts create mode 100644 src/api/event-other/content-types/event-other/schema.json create mode 100644 src/api/event-other/controllers/event-other.ts create mode 100644 src/api/event-other/routes/event-other.ts create mode 100644 src/api/event-other/services/event-other.ts diff --git a/config/plugins.ts b/config/plugins.ts index f5c979c..2e12bb9 100644 --- a/config/plugins.ts +++ b/config/plugins.ts @@ -39,4 +39,10 @@ export default () => ({ }, }, }, + "strapi-v5-plugin-populate-deep": { + config: { + defaultDepth: 3, // Default is 5 + skipCreatorFields: false, + }, + }, }); diff --git a/src/api/announcement/content-types/announcement/schema.json b/src/api/announcement/content-types/announcement/schema.json new file mode 100644 index 0000000..8ff616e --- /dev/null +++ b/src/api/announcement/content-types/announcement/schema.json @@ -0,0 +1,34 @@ +{ + "kind": "collectionType", + "collectionName": "announcements", + "info": { + "singularName": "announcement", + "pluralName": "announcements", + "displayName": "Announcement", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "choral": { + "type": "relation", + "relation": "manyToOne", + "target": "api::choral.choral", + "inversedBy": "announcements" + }, + "author": { + "type": "relation", + "relation": "manyToOne", + "target": "plugin::users-permissions.user", + "inversedBy": "announcements" + } + } +} diff --git a/src/api/announcement/controllers/announcement.ts b/src/api/announcement/controllers/announcement.ts new file mode 100644 index 0000000..e847e8f --- /dev/null +++ b/src/api/announcement/controllers/announcement.ts @@ -0,0 +1,7 @@ +/** + * announcement controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::announcement.announcement'); diff --git a/src/api/announcement/routes/announcement.ts b/src/api/announcement/routes/announcement.ts new file mode 100644 index 0000000..12a0d9d --- /dev/null +++ b/src/api/announcement/routes/announcement.ts @@ -0,0 +1,7 @@ +/** + * announcement router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::announcement.announcement'); diff --git a/src/api/announcement/services/announcement.ts b/src/api/announcement/services/announcement.ts new file mode 100644 index 0000000..d6e5307 --- /dev/null +++ b/src/api/announcement/services/announcement.ts @@ -0,0 +1,7 @@ +/** + * announcement service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::announcement.announcement'); diff --git a/src/api/choral/content-types/choral/schema.json b/src/api/choral/content-types/choral/schema.json index 2d27b7c..63087cf 100644 --- a/src/api/choral/content-types/choral/schema.json +++ b/src/api/choral/content-types/choral/schema.json @@ -88,6 +88,12 @@ "relation": "oneToMany", "target": "api::choral-membership.choral-membership", "mappedBy": "choral" + }, + "announcements": { + "type": "relation", + "relation": "oneToMany", + "target": "api::announcement.announcement", + "mappedBy": "choral" } } } diff --git a/src/api/event-other/content-types/event-other/schema.json b/src/api/event-other/content-types/event-other/schema.json new file mode 100644 index 0000000..db8fb09 --- /dev/null +++ b/src/api/event-other/content-types/event-other/schema.json @@ -0,0 +1,42 @@ +{ + "kind": "collectionType", + "collectionName": "event_others", + "info": { + "singularName": "event-other", + "pluralName": "event-others", + "displayName": "EventOther" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "title": { + "type": "string" + }, + "public": { + "type": "boolean" + }, + "fromDate": { + "type": "datetime" + }, + "toDate": { + "type": "datetime" + }, + "type": { + "type": "enumeration", + "enum": [ + "concert", + "festival", + "salon", + "symposium", + "concours", + "masterclass", + "atelier vocal", + "conférence", + "répétition", + "sorties" + ] + } + } +} diff --git a/src/api/event-other/controllers/event-other.ts b/src/api/event-other/controllers/event-other.ts new file mode 100644 index 0000000..b52ccea --- /dev/null +++ b/src/api/event-other/controllers/event-other.ts @@ -0,0 +1,7 @@ +/** + * event-other controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::event-other.event-other'); diff --git a/src/api/event-other/routes/event-other.ts b/src/api/event-other/routes/event-other.ts new file mode 100644 index 0000000..10898b4 --- /dev/null +++ b/src/api/event-other/routes/event-other.ts @@ -0,0 +1,7 @@ +/** + * event-other router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::event-other.event-other'); diff --git a/src/api/event-other/services/event-other.ts b/src/api/event-other/services/event-other.ts new file mode 100644 index 0000000..ffa537f --- /dev/null +++ b/src/api/event-other/services/event-other.ts @@ -0,0 +1,7 @@ +/** + * event-other service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::event-other.event-other'); diff --git a/src/extensions/users-permissions/content-types/user/schema.json b/src/extensions/users-permissions/content-types/user/schema.json index 0756a80..7b6342f 100644 --- a/src/extensions/users-permissions/content-types/user/schema.json +++ b/src/extensions/users-permissions/content-types/user/schema.json @@ -175,6 +175,12 @@ "relation": "oneToMany", "target": "api::choral-membership.choral-membership", "mappedBy": "user" + }, + "announcements": { + "type": "relation", + "relation": "oneToMany", + "target": "api::announcement.announcement", + "mappedBy": "author" } } } diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index 99011e3..c04e5a8 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -369,6 +369,42 @@ export interface AdminUser extends Struct.CollectionTypeSchema { }; } +export interface ApiAnnouncementAnnouncement + extends Struct.CollectionTypeSchema { + collectionName: 'announcements'; + info: { + description: ''; + displayName: 'Announcement'; + pluralName: 'announcements'; + singularName: 'announcement'; + }; + options: { + draftAndPublish: false; + }; + attributes: { + author: Schema.Attribute.Relation< + 'manyToOne', + 'plugin::users-permissions.user' + >; + choral: Schema.Attribute.Relation<'manyToOne', 'api::choral.choral'>; + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + description: Schema.Attribute.String; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation< + 'oneToMany', + 'api::announcement.announcement' + > & + Schema.Attribute.Private; + publishedAt: Schema.Attribute.DateTime; + title: Schema.Attribute.String; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + }; +} + export interface ApiBoardCardBoardCard extends Struct.CollectionTypeSchema { collectionName: 'board_cards'; info: { @@ -564,6 +600,10 @@ export interface ApiChoralChoral extends Struct.CollectionTypeSchema { 'manyToMany', 'plugin::users-permissions.user' >; + announcements: Schema.Attribute.Relation< + 'oneToMany', + 'api::announcement.announcement' + >; boards: Schema.Attribute.Relation<'oneToMany', 'api::board.board'>; calendar: Schema.Attribute.Relation<'oneToMany', 'api::event.event'>; city: Schema.Attribute.String; @@ -606,6 +646,51 @@ export interface ApiChoralChoral extends Struct.CollectionTypeSchema { }; } +export interface ApiEventOtherEventOther extends Struct.CollectionTypeSchema { + collectionName: 'event_others'; + info: { + displayName: 'EventOther'; + pluralName: 'event-others'; + singularName: 'event-other'; + }; + options: { + draftAndPublish: false; + }; + attributes: { + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + fromDate: Schema.Attribute.DateTime; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation< + 'oneToMany', + 'api::event-other.event-other' + > & + Schema.Attribute.Private; + public: Schema.Attribute.Boolean; + publishedAt: Schema.Attribute.DateTime; + title: Schema.Attribute.String; + toDate: Schema.Attribute.DateTime; + type: Schema.Attribute.Enumeration< + [ + 'concert', + 'festival', + 'salon', + 'symposium', + 'concours', + 'masterclass', + 'atelier vocal', + 'conf\u00E9rence', + 'r\u00E9p\u00E9tition', + 'sorties', + ] + >; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + }; +} + export interface ApiEventEvent extends Struct.CollectionTypeSchema { collectionName: 'events'; info: { @@ -1127,6 +1212,10 @@ export interface PluginUsersPermissionsUser }; attributes: { address: Schema.Attribute.Text; + announcements: Schema.Attribute.Relation< + 'oneToMany', + 'api::announcement.announcement' + >; avatar: Schema.Attribute.Media<'images'>; background: Schema.Attribute.Media< 'images' | 'files' | 'videos' | 'audios' @@ -1208,12 +1297,14 @@ declare module '@strapi/strapi' { 'admin::transfer-token': AdminTransferToken; 'admin::transfer-token-permission': AdminTransferTokenPermission; 'admin::user': AdminUser; + 'api::announcement.announcement': ApiAnnouncementAnnouncement; 'api::board-card.board-card': ApiBoardCardBoardCard; 'api::board-list.board-list': ApiBoardListBoardList; 'api::board.board': ApiBoardBoard; 'api::choral-membership.choral-membership': ApiChoralMembershipChoralMembership; 'api::choral-permission.choral-permission': ApiChoralPermissionChoralPermission; 'api::choral.choral': ApiChoralChoral; + 'api::event-other.event-other': ApiEventOtherEventOther; 'api::event.event': ApiEventEvent; 'api::permissions-template.permissions-template': ApiPermissionsTemplatePermissionsTemplate; 'plugin::content-releases.release': PluginContentReleasesRelease;