Skip to content

Commit 2432bb7

Browse files
authored
Merge pull request #4 from pythonkr/feature/cms-api
feat: cms Page & Sitemap list, retrieve API 추가
2 parents cc655eb + 7e2c316 commit 2432bb7

15 files changed

Lines changed: 416 additions & 85 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ipython_config.py
9999
# This is especially recommended for binary packages to ensure reproducibility, and is more
100100
# commonly ignored for libraries.
101101
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102-
#poetry.lock
102+
poetry.lock
103103

104104
# pdm
105105
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.

.pre-commit-config.yaml

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,84 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
default_language_version:
4-
python: python3.12
4+
python: python3.12
55
default_stages: [pre-commit, pre-push]
66
repos:
7-
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
9-
hooks:
10-
- id: check-toml
11-
- id: check-xml
12-
- id: check-yaml
13-
- id: check-added-large-files
14-
- id: detect-aws-credentials
15-
args:
16-
- --allow-missing-credentials
17-
- id: end-of-file-fixer
18-
- id: mixed-line-ending
19-
- id: pretty-format-json
20-
args:
21-
- --autofix
22-
- id: trailing-whitespace
23-
exclude_types:
24-
- javascript
25-
- markdown
26-
- repo: https://github.com/PyCQA/flake8
27-
rev: 7.2.0
28-
hooks:
29-
- id: flake8
30-
additional_dependencies:
31-
- flake8-bugbear
32-
- flake8-noqa
33-
args:
34-
- --max-line-length=120
35-
- --max-complexity=18
36-
- repo: https://github.com/psf/black
37-
rev: 25.1.0
38-
hooks:
39-
- id: black
40-
language_version: python3.12
41-
args:
42-
- --line-length=120
43-
- repo: https://github.com/PyCQA/bandit
44-
rev: '1.8.3'
45-
hooks:
46-
- id: bandit
47-
- repo: https://github.com/PyCQA/isort
48-
rev: '6.0.1'
49-
hooks:
50-
- id: isort
51-
- repo: https://github.com/dosisod/refurb
52-
rev: v2.0.0
53-
hooks:
54-
- id: refurb
55-
additional_dependencies:
56-
- boto3
57-
- django-constance
58-
- django-cors-headers
59-
- django-environ
60-
- django-extensions
61-
- django-filter
62-
- django-simple-history
63-
- django-stubs[compatible-mypy]
64-
- drf-spectacular
65-
- drf-standardized-errors
66-
- djangorestframework-stubs[compatible-mypy]
67-
- zappa-django-utils
68-
- repo: https://github.com/astral-sh/uv-pre-commit
69-
rev: 0.6.12
70-
hooks:
71-
- id: uv-lock
72-
- repo: https://github.com/astral-sh/ruff-pre-commit
73-
rev: v0.11.4
74-
hooks:
75-
- id: ruff
76-
args:
77-
- --fix
78-
- id: ruff-format
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: check-toml
11+
- id: check-xml
12+
- id: check-yaml
13+
- id: check-added-large-files
14+
- id: detect-aws-credentials
15+
args:
16+
- --allow-missing-credentials
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
- id: pretty-format-json
20+
args:
21+
- --autofix
22+
- id: trailing-whitespace
23+
exclude_types:
24+
- javascript
25+
- markdown
26+
- repo: https://github.com/PyCQA/flake8
27+
rev: 7.2.0
28+
hooks:
29+
- id: flake8
30+
additional_dependencies:
31+
- flake8-bugbear
32+
- flake8-noqa
33+
args:
34+
- --max-line-length=120
35+
- --max-complexity=18
36+
- repo: https://github.com/psf/black
37+
rev: 25.1.0
38+
hooks:
39+
- id: black
40+
language_version: python3.12
41+
args:
42+
- --line-length=120
43+
- repo: https://github.com/PyCQA/bandit
44+
rev: "1.8.3"
45+
hooks:
46+
- id: bandit
47+
args:
48+
- -c
49+
- bandit.yaml
50+
- repo: https://github.com/PyCQA/isort
51+
rev: "6.0.1"
52+
hooks:
53+
- id: isort
54+
- repo: https://github.com/dosisod/refurb
55+
rev: v2.0.0
56+
hooks:
57+
- id: refurb
58+
additional_dependencies:
59+
- boto3
60+
- django-constance
61+
- django-cors-headers
62+
- django-environ
63+
- django-extensions
64+
- django-filter
65+
- django-simple-history
66+
- django-stubs[compatible-mypy]
67+
- drf-spectacular
68+
- drf-standardized-errors
69+
- djangorestframework-stubs[compatible-mypy]
70+
- zappa-django-utils
71+
- repo: https://github.com/astral-sh/uv-pre-commit
72+
rev: 0.6.12
73+
hooks:
74+
- id: uv-lock
75+
- repo: https://github.com/astral-sh/ruff-pre-commit
76+
rev: v0.11.4
77+
hooks:
78+
- id: ruff
79+
args:
80+
- --fix
81+
- id: ruff-format
7982
# - repo: https://github.com/pre-commit/mirrors-mypy
8083
# rev: 'v1.15.0'
8184
# hooks:

app/cms/apps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import importlib
2+
13
from django.apps import AppConfig
24

35

46
class CmsConfig(AppConfig):
57
name = "cms"
8+
9+
def ready(self):
10+
importlib.import_module("cms.translation")
11+
12+
from cms.models import Page, Section, Sitemap
13+
from simple_history import register
14+
15+
register(Page)
16+
register(Sitemap)
17+
register(Section)
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Generated by Django 5.2 on 2025-04-21 13:38
2+
3+
import uuid
4+
5+
import django.db.models.deletion
6+
import simple_history.models
7+
from django.conf import settings
8+
from django.db import migrations, models
9+
10+
11+
class Migration(migrations.Migration):
12+
dependencies = [
13+
("cms", "0001_initial"),
14+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15+
]
16+
17+
operations = [
18+
migrations.CreateModel(
19+
name="HistoricalPage",
20+
fields=[
21+
(
22+
"id",
23+
models.UUIDField(db_index=True, default=uuid.uuid4, editable=False),
24+
),
25+
("is_active", models.BooleanField(default=False)),
26+
("css", models.TextField(blank=True, default=None, null=True)),
27+
("title", models.CharField(max_length=256)),
28+
("title_ko", models.CharField(max_length=256, null=True)),
29+
("title_en", models.CharField(max_length=256, null=True)),
30+
("subtitle", models.CharField(max_length=512)),
31+
("subtitle_ko", models.CharField(max_length=512, null=True)),
32+
("subtitle_en", models.CharField(max_length=512, null=True)),
33+
("history_id", models.AutoField(primary_key=True, serialize=False)),
34+
("history_date", models.DateTimeField(db_index=True)),
35+
("history_change_reason", models.CharField(max_length=100, null=True)),
36+
(
37+
"history_type",
38+
models.CharField(
39+
choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
40+
max_length=1,
41+
),
42+
),
43+
(
44+
"history_user",
45+
models.ForeignKey(
46+
null=True,
47+
on_delete=django.db.models.deletion.SET_NULL,
48+
related_name="+",
49+
to=settings.AUTH_USER_MODEL,
50+
),
51+
),
52+
],
53+
options={
54+
"verbose_name": "historical page",
55+
"verbose_name_plural": "historical pages",
56+
"ordering": ("-history_date", "-history_id"),
57+
"get_latest_by": ("history_date", "history_id"),
58+
},
59+
bases=(simple_history.models.HistoricalChanges, models.Model),
60+
),
61+
migrations.CreateModel(
62+
name="HistoricalSection",
63+
fields=[
64+
(
65+
"id",
66+
models.UUIDField(db_index=True, default=uuid.uuid4, editable=False),
67+
),
68+
("order", models.IntegerField(default=0)),
69+
("css", models.TextField(blank=True, default=None, null=True)),
70+
(
71+
"body",
72+
models.TextField(help_text="Content of the page, Written in markdown format"),
73+
),
74+
(
75+
"body_ko",
76+
models.TextField(
77+
help_text="Content of the page, Written in markdown format",
78+
null=True,
79+
),
80+
),
81+
(
82+
"body_en",
83+
models.TextField(
84+
help_text="Content of the page, Written in markdown format",
85+
null=True,
86+
),
87+
),
88+
("history_id", models.AutoField(primary_key=True, serialize=False)),
89+
("history_date", models.DateTimeField(db_index=True)),
90+
("history_change_reason", models.CharField(max_length=100, null=True)),
91+
(
92+
"history_type",
93+
models.CharField(
94+
choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
95+
max_length=1,
96+
),
97+
),
98+
(
99+
"history_user",
100+
models.ForeignKey(
101+
null=True,
102+
on_delete=django.db.models.deletion.SET_NULL,
103+
related_name="+",
104+
to=settings.AUTH_USER_MODEL,
105+
),
106+
),
107+
(
108+
"page",
109+
models.ForeignKey(
110+
blank=True,
111+
db_constraint=False,
112+
null=True,
113+
on_delete=django.db.models.deletion.DO_NOTHING,
114+
related_name="+",
115+
to="cms.page",
116+
),
117+
),
118+
],
119+
options={
120+
"verbose_name": "historical section",
121+
"verbose_name_plural": "historical sections",
122+
"ordering": ("-history_date", "-history_id"),
123+
"get_latest_by": ("history_date", "history_id"),
124+
},
125+
bases=(simple_history.models.HistoricalChanges, models.Model),
126+
),
127+
migrations.CreateModel(
128+
name="HistoricalSitemap",
129+
fields=[
130+
(
131+
"id",
132+
models.UUIDField(db_index=True, default=uuid.uuid4, editable=False),
133+
),
134+
("name", models.CharField(max_length=256)),
135+
("name_ko", models.CharField(max_length=256, null=True)),
136+
("name_en", models.CharField(max_length=256, null=True)),
137+
("order", models.IntegerField(default=0)),
138+
("display_start_at", models.DateTimeField(blank=True, null=True)),
139+
("display_end_at", models.DateTimeField(blank=True, null=True)),
140+
("history_id", models.AutoField(primary_key=True, serialize=False)),
141+
("history_date", models.DateTimeField(db_index=True)),
142+
("history_change_reason", models.CharField(max_length=100, null=True)),
143+
(
144+
"history_type",
145+
models.CharField(
146+
choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
147+
max_length=1,
148+
),
149+
),
150+
(
151+
"history_user",
152+
models.ForeignKey(
153+
null=True,
154+
on_delete=django.db.models.deletion.SET_NULL,
155+
related_name="+",
156+
to=settings.AUTH_USER_MODEL,
157+
),
158+
),
159+
(
160+
"page",
161+
models.ForeignKey(
162+
blank=True,
163+
db_constraint=False,
164+
null=True,
165+
on_delete=django.db.models.deletion.DO_NOTHING,
166+
related_name="+",
167+
to="cms.page",
168+
),
169+
),
170+
(
171+
"parent_sitemap",
172+
models.ForeignKey(
173+
blank=True,
174+
db_constraint=False,
175+
default=None,
176+
null=True,
177+
on_delete=django.db.models.deletion.DO_NOTHING,
178+
related_name="+",
179+
to="cms.sitemap",
180+
),
181+
),
182+
],
183+
options={
184+
"verbose_name": "historical sitemap",
185+
"verbose_name_plural": "historical sitemaps",
186+
"ordering": ("-history_date", "-history_id"),
187+
"get_latest_by": ("history_date", "history_id"),
188+
},
189+
bases=(simple_history.models.HistoricalChanges, models.Model),
190+
),
191+
]

0 commit comments

Comments
 (0)