Skip to content

feat: CMS Sitemap을 frontend 도메인 그룹으로 필터링#41

Merged
MU-Software merged 3 commits intomainfrom
feature/add-applied-domain-to-cms
May 9, 2026
Merged

feat: CMS Sitemap을 frontend 도메인 그룹으로 필터링#41
MU-Software merged 3 commits intomainfrom
feature/add-applied-domain-to-cms

Conversation

@MU-Software
Copy link
Copy Markdown
Member

배경

  • 여러 frontend 도메인(예: 2025.pycon.kr, 2026.pycon.kr 등)이 단일 CMS 백엔드를 공유하면서 도메인별로 다른 sitemap을 노출해야 함.
    기존엔 한 sitemap 트리만 존재하여 도메인별 분리가 불가능.

변경 요약

1. 모델 / 마이그레이션

  • DomainGroup 모델 신규 추가
  • Sitemap.domain_group FK (on_delete=PROTECT) 추가
  • Sitemap unique constraint를 (domain_group, parent_sitemap, route_code)로 교체 — 그룹이 다르면 같은 route_code 허용
  • 단일 마이그레이션 0013이 4단계로 처리:
    1. DomainGroup/HistoricalDomainGroup 생성 + Sitemap.domain_group을 일시 nullable로 추가
    2. 2025년 PyConKR 홈페이지 그룹 생성 후 기존 Sitemap 일괄 연결
    3. Sitemap.domain_group을 NOT NULL로 변경 + unique constraint 교체
    4. 그룹 간 도메인 중복을 막는 PostgreSQL trigger 설치 (advisory lock으로 race-safe)

2. Public API (cms/views.py)

  • SitemapViewSet.list가 요청 도메인을 다음 우선순위로 추출하여 매칭되는 sitemap만 반환:
    ?frontend-domain= query → X-Frontend-Domain header → OriginReferer
  • 도메인을 결정할 수 없으면 404, 결정은 됐지만 매칭 그룹이 없으면 빈 결과
  • 도메인 정규화: 호스트만 추출 (스킴/포트/경로/쿼리 제거, lowercase)

3. Admin API (admin_api/)

  • DomainGroupAdminViewSet 신규 (/v1/admin/cms/domain-group/)
  • DomainGroupAdminSerializer.validate_domains:
    • strip + lowercase + dedupe (set comprehension으로 정규화)
    • 호스트 형식 검증 (core/const/regex.pyHOSTNAME_REGEX)
    • 그룹 간 도메인 중복 거부 (app-level)
  • 그룹 생성/수정 시 sitemap이 없으면 default Page + Section + Sitemap 자동 생성
  • 그룹 삭제 시 lone-root sitemap만 같이 정리. 다중 sitemap이나 hierarchy가 있으면 거부
  • SitemapAdminSerializerdomain_group 필드 노출, ?domain_group=<uuid> 필터 지원

@MU-Software MU-Software merged commit f8bf950 into main May 9, 2026
1 check passed
@MU-Software MU-Software deleted the feature/add-applied-domain-to-cms branch May 9, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant