Admin QT 테마 CRUD + 라우트 + 사이드바 + 테스트
ID: 5205ccfd-4098-48e3-80f5-48deba524045
## 목표
Admin namespace에 QT 테마 CRUD 구현
## 구현 항목
### 1. Admin::QtThemesController (신규)
- 파일: `app/controllers/admin/qt_themes_controller.rb`
- Admin::BaseController 상속
- 액션: index, show, new, create, edit, update, destroy
- index: QtTheme.order(created_at: :desc), 페이지네이션 불필요 (수량 적음)
- show: @theme + @theme.qt_contents.order(:day_number)
- new/create: QtTheme.new / .build
- edit/update: 기본 CRUD
- destroy: 연관 콘텐츠 있으면 삭제 경고
- 추가 액션: `toggle_active` (PATCH) - is_active 토글
- 추가 액션: `update_status` (PATCH) - generation_status 변경
- strong params: title, description, is_default, is_active, total_day, is_ai_generated, ai_prompt, bible_books, generation_status
### 2. 라우트 수정
- `config/routes.rb`의 admin namespace에 추가:
```ruby
namespace :admin do
root "dashboard#index"
resources :qt_themes do
member do
patch :toggle_active
patch :update_status
end
resources :qt_contents
end
end
```
### 3. 사이드바 수정
- `app/views/admin/shared/_sidebar.html.erb`
- 대시보드 링크와 separator 사이에 QT 테마 메뉴 추가:
- "QT 테마 관리" (admin_qt_themes_path) - 책 아이콘 SVG
### 4. 뷰 (신규)
- `app/views/admin/qt_themes/index.html.erb`:
- 제목 "QT 테마 관리" + "새 테마" 버튼
- shared/_table.html.erb로 목록 (헤더: 제목, 일수, 상태, 활성, 생성일, 액션)
- generation_status는 shared/_badge.html.erb로 표시 (draft=info, generating=warning, completed=success, published=success)
- is_active는 토글 버튼
- 액션: 보기, 수정, 삭제 링크
- `app/views/admin/qt_themes/show.html.erb`:
- 테마 상세 정보 카드
- 콘텐츠 목록 (shared/_table.html.erb) + "콘텐츠 추가" 버튼
- 상태 변경 버튼들 (draft→generating→completed→published)
- `app/views/admin/qt_themes/new.html.erb` + `edit.html.erb`:
- _form.html.erb 파셜 렌더링
- `app/views/admin/qt_themes/_form.html.erb`:
- shared/_input.html.erb 사용: title(required), description(textarea), total_day(number, required), bible_books, ai_prompt
- shared/_select.html.erb 사용: generation_status
- 체크박스: is_default, is_active, is_ai_generated (Tailwind 스타일 직접 구현)
- 제출/취소 버튼
### 5. 테스트 (신규)
- `test/controllers/admin/qt_themes_controller_test.rb`
- 테스트 케이스:
- admin 로그인 후 테마 목록 조회 (GET /admin/qt_themes)
- admin 로그인 후 테마 생성 (POST /admin/qt_themes)
- admin 로그인 후 테마 수정 (PATCH /admin/qt_themes/:id)
- admin 로그인 후 테마 삭제 (DELETE /admin/qt_themes/:id)
- admin 로그인 후 활성화 토글 (PATCH /admin/qt_themes/:id/toggle_active)
- admin 로그인 후 상태 변경 (PATCH /admin/qt_themes/:id/update_status)
- 일반 사용자 접근 차단
- Fixture: qt_themes(:default_theme), users(:admin)
## 주의사항
- UUID PK (ApplicationRecord의 set_uuid)
- ERB 멀티라인 주석 금지
- shared 파셜 strict locals 정확히 준수:
- _table: headers:, rows:, empty_message: "데이터가 없습니다."
- _badge: text:, variant: :info
- _input: form:, field:, label:, type: :text, required: false, hint: nil, placeholder: nil
- _select: form:, field:, label:, options:, selected: nil, required: false, include_blank: "선택하세요", hint: nil
- _card: variant: :default, padding: :md
- _separator: (no locals)
- Tailwind CSS v4 의미 기반 색상 사용
- 전체 테스트 통과 확인: bin/rails test
첨부 이미지
이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)
JPEG, PNG, GIF, WebP / 최대 10MB
활동 로그
-
팀팀리드 상태 변경: 리뷰 → 완료
2026년 03월 02일 05:12:36
-
Aadmin-themes 상태 변경: 할 일 → 리뷰
2026년 03월 02일 05:08:20
-
Aadmin-themes Admin QT 테마 CRUD 구현 완료
2026년 03월 02일 05:08:20
상세 보기
## 생성/수정된 파일
### 컨트롤러
- `app/controllers/admin/qt_themes_controller.rb` - CRUD + toggle_active + update_status### 뷰 (5개)
- `app/views/admin/qt_themes/index.html.erb` - 테마 목록 (shared/_table, _badge 활용)
- `app/views/admin/qt_themes/show.html.erb` - 테마 상세 + 콘텐츠 목록 + 상태 변경 버튼
- `app/views/admin/qt_themes/new.html.erb` - 새 테마 생성
- `app/views/admin/qt_themes/edit.html.erb` - 테마 수정
- `app/views/admin/qt_themes/_form.html.erb` - 공통 폼 (shared/_input, _select 활용)### 수정된 파일
- `config/routes.rb` - admin namespace에 qt_themes + qt_contents 리소스 추가
- `app/views/admin/shared/_sidebar.html.erb` - "QT 테마 관리" 메뉴 추가### 테스트
- `test/controllers/admin/qt_themes_controller_test.rb` - 13 tests, 33 assertions (all pass)## 테스트 결과
- 전체 테스트: 375 runs, 856 assertions, 0 failures, 0 errors -
Aadmin-themes Admin QT 테마 CRUD 작업 시작
2026년 03월 02일 05:04:20
상세 보기
## 작업 범위
- Admin::QtThemesController CRUD
- 라우트 추가
- 사이드바 메뉴 추가
- 뷰 파일 (index, show, new, edit, _form)
- 테스트 (admin/qt_themes_controller_test.rb)