diff --git a/proto/scripts/migrate-content-to-payload.ts b/proto/scripts/migrate-content-to-payload.ts index 1c54d3e..95208b9 100644 --- a/proto/scripts/migrate-content-to-payload.ts +++ b/proto/scripts/migrate-content-to-payload.ts @@ -100,7 +100,7 @@ function buildHomeData(json: typeof homeJson) { function partnerMeta(name: string) { const confirmed = CONFIRMED_CLIENT_REFERENCES.find((c) => c.name === name) return confirmed - ? { relationship: 'client-reference' as const, publicationPermission: 'granted' as const, permissionReference: confirmed.permissionReference } + ? { relationship: 'client-reference' as const, publicationPermission: confirmed.permission, permissionReference: confirmed.permissionReference } : { relationship: 'client-reference' as const, publicationPermission: 'none' as const } } diff --git a/proto/src/__tests__/partner-references-migration.test.ts b/proto/src/__tests__/partner-references-migration.test.ts index d0cd2f1..4aae561 100644 --- a/proto/src/__tests__/partner-references-migration.test.ts +++ b/proto/src/__tests__/partner-references-migration.test.ts @@ -1,4 +1,5 @@ import { classifyPartner, seedReferencesSection, up } from '../migrations/20260929_partner_references' +import { markAtlantiszPending, PENDING_REFERENCE } from '../migrations/20260929_atlantisz_pending' import { fakeArgs, fakeCollection } from './helpers/fake-mongo' type Doc = Record @@ -11,10 +12,25 @@ describe('20260929_partner_references migration (MITHOME-131)', () => { expect(doc.permissionReference).toMatch(/Írásos engedély/) }) - it('should mark the Atlantisz contracted client as a client reference too', () => { + it('should mark the Atlantisz contracted client as a client reference, pending until its logo is settled', () => { const doc: Doc = { name: 'Atlantisz Horgászüdülő és Halásztanya' } classifyPartner(doc) - expect(doc).toMatchObject({ relationship: 'client-reference', publicationPermission: 'granted' }) + expect(doc).toMatchObject({ relationship: 'client-reference', publicationPermission: 'pending' }) + }) + + it('should move an already granted Atlantisz entry to pending, but respect later admin decisions', () => { + const auto: Doc = { + name: 'Atlantisz Horgászüdülő és Halásztanya', + publicationPermission: 'granted', + permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)', + } + expect(markAtlantiszPending(auto)).toBe(1) + expect(auto).toMatchObject({ publicationPermission: 'pending', permissionReference: PENDING_REFERENCE }) + expect(markAtlantiszPending(auto)).toBe(0) + const admin: Doc = { name: 'Atlantisz Horgászüdülő és Halásztanya', publicationPermission: 'granted', permissionReference: 'E-mail, 2026-10-05' } + expect(markAtlantiszPending(admin)).toBe(0) + const angele: Doc = { name: 'Angele Pihenőház', publicationPermission: 'granted', permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)' } + expect(markAtlantiszPending(angele)).toBe(0) }) it('should hide any other uncategorised entry until someone classifies it', () => { diff --git a/proto/src/migrations/20260929_atlantisz_pending.ts b/proto/src/migrations/20260929_atlantisz_pending.ts new file mode 100644 index 0000000..282f95d --- /dev/null +++ b/proto/src/migrations/20260929_atlantisz_pending.ts @@ -0,0 +1,42 @@ +/** + * MITHOME-133: az Atlantisz Horgászüdülő és Halásztanya bejegyzést + * "Egyeztetés alatt" állapotba teszi, amíg a logó (fehér felirat, világos + * háttéren olvashatatlan) és a hivatalos név rendeződik. + * + * WHY külön migráció: a 20260929_partner_references a stagingen már + * "granted" állapottal lefutott; a még le nem futott környezetekben az + * eleve "pending"-et állít. Csak a saját, automatikus besorolást írja + * felül (egyező permissionReference) — egy későbbi admin-döntéshez nem nyúl. + */ +import type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/db-mongodb' + +import { rewriteDocs } from '../lib/migrate-global-docs' + +const NAME = 'Atlantisz Horgászüdülő és Halásztanya' +const AUTO_GRANTED_REFERENCE = 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)' +export const PENDING_REFERENCE = 'Írásos engedély megvan; logó és hivatalos név egyeztetés alatt (MITHOME-133)' + +export function markAtlantiszPending(doc: Record): number { + if (doc.name !== NAME || doc.publicationPermission !== 'granted' || doc.permissionReference !== AUTO_GRANTED_REFERENCE) { + return 0 + } + doc.publicationPermission = 'pending' + doc.permissionReference = PENDING_REFERENCE + return 1 +} + +export async function up(args: MigrateUpArgs): Promise { + const changed = await rewriteDocs( + args, + { kind: 'collection', slug: 'partners' }, + ['publicationPermission', 'permissionReference'], + markAtlantiszPending, + { versions: 'latest' }, + ) + args.payload.logger.info(`MITHOME-133 Atlantisz: ${changed} record(s) set to pending`) +} + +/** DECISION: no automatic down — set the status in the admin instead. */ +export async function down(args: MigrateDownArgs): Promise { + args.payload.logger.warn('MITHOME-133 Atlantisz: down is a no-op — change the status in the admin instead') +} diff --git a/proto/src/migrations/20260929_partner_references.ts b/proto/src/migrations/20260929_partner_references.ts index ae0fdc1..1f8e202 100644 --- a/proto/src/migrations/20260929_partner_references.ts +++ b/proto/src/migrations/20260929_partner_references.ts @@ -20,13 +20,17 @@ type Data = Record export const CONFIRMED_CLIENT_REFERENCES = [ { name: 'Angele Pihenőház', + permission: 'granted', permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)', }, { // Contracted client (its site runs on our infrastructure) — a client // reference, not a partner, per the research's categories. + // Kept "pending" until the logo (white text, unreadable on a light + // background) and the official name are settled (MITHOME-133). name: 'Atlantisz Horgászüdülő és Halásztanya', - permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)', + permission: 'pending', + permissionReference: 'Írásos engedély megvan; logó és hivatalos név egyeztetés alatt (MITHOME-133)', }, ] as const @@ -63,7 +67,7 @@ export function classifyPartner(doc: Data): number { const confirmed = CONFIRMED_CLIENT_REFERENCES.find((c) => c.name === doc.name) if (confirmed) { doc.relationship = 'client-reference' - doc.publicationPermission = 'granted' + doc.publicationPermission = confirmed.permission doc.permissionReference = confirmed.permissionReference } else { doc.publicationPermission = 'none' diff --git a/proto/src/migrations/index.ts b/proto/src/migrations/index.ts index b9678dd..0cddff9 100644 --- a/proto/src/migrations/index.ts +++ b/proto/src/migrations/index.ts @@ -4,6 +4,7 @@ import * as migration_20260929_localize_legal_pages from './20260929_localize_le import * as migration_20260929_en_ai_draft from './20260929_en_ai_draft' import * as migration_20260929_service_claims from './20260929_service_claims' import * as migration_20260929_partner_references from './20260929_partner_references' +import * as migration_20260929_atlantisz_pending from './20260929_atlantisz_pending' /** * Payload migrations, in order. Passed to `mongooseAdapter({ prodMigrations })` @@ -45,4 +46,10 @@ export const migrations = [ down: migration_20260929_partner_references.down, name: '20260929_partner_references', }, + { + // MITHOME-133 — Atlantisz on hold until logo and official name are settled. + up: migration_20260929_atlantisz_pending.up, + down: migration_20260929_atlantisz_pending.down, + name: '20260929_atlantisz_pending', + }, ]