Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mise en place d’un système de modèles de pages #218

Merged
merged 17 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HOST_URL=localhost
ALLOWED_HOSTS=localhost, 127.0.0.1
HOST_PORT=8000
SITE_NAME=Sites faciles
MEDIA_ROOT=
MEDIA_ROOT=medias

# USE_DOCKER: Set 1 to use Docker
USE_DOCKER=0
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ jobs:
- name: 🤹‍ Run the unit tests
run: |
make test-unit
- name: 🎨 Deploy starter content
run: |
make init
poetry run python manage.py create_demo_pages
env:
DJANGO_DEBUG: True
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ endif
web-prompt:
$(EXEC_CMD) bash

.PHONY: test-unit
test-unit:
$(EXEC_CMD) poetry run python manage.py test --settings config.settings_test

.PHONY: collectstatic
collectstatic:
$(EXEC_CMD) poetry run python manage.py collectstatic --noinput --ignore=*.sass
Expand Down Expand Up @@ -54,6 +50,7 @@ init:
$(EXEC_CMD) poetry run python manage.py set_config
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py create_starter_pages
$(EXEC_CMD) poetry run python manage.py import_page_templates
make index

.PHONY: init-dev
Expand Down Expand Up @@ -84,3 +81,7 @@ runserver:
.PHONY: test
test:
$(EXEC_CMD) poetry run python manage.py test --buffer --parallel

.PHONY: test-unit
test-unit:
$(EXEC_CMD) poetry run python manage.py test --settings config.settings_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.1.1 on 2024-09-23 13:57

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("blog", "0035_alter_blogentrypage_body_alter_blogindexpage_body_and_more"),
]

operations = [
migrations.AddField(
model_name="blogentrypage",
name="source_url",
field=models.URLField(
blank=True, help_text="For imported pages, to allow updates.", null=True, verbose_name="Source URL"
),
),
migrations.AddField(
model_name="blogindexpage",
name="source_url",
field=models.URLField(
blank=True, help_text="For imported pages, to allow updates.", null=True, verbose_name="Source URL"
),
),
]
20 changes: 20 additions & 0 deletions content_manager/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class SitesFacilesBasePage(Page):
blank=True,
)

source_url = models.URLField(
_("Source URL"),
help_text=_("For imported pages, to allow updates."),
null=True,
blank=True,
)

content_panels = Page.content_panels + [
FieldPanel("body", heading=_("Body")),
]
Expand Down Expand Up @@ -126,8 +133,21 @@ class SitesFacilesBasePage(Page):
APIField("header_cta_buttons"),
APIField("header_cta_label"),
APIField("header_cta_link"),
APIField("public_child_pages"),
]

@property
def public_child_pages(self):
return [
{
"id": child.id,
"slug": child.slug,
"title": child.title,
"type": f"{child.content_type.app_label}.{child.content_type.model}",
}
for child in self.get_children().live().public()
]

def get_absolute_url(self):
return self.url

Expand Down
12 changes: 12 additions & 0 deletions content_manager/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
from django.utils.translation import gettext_lazy as _

HEADER_FIELDS = [
"header_image",
"header_with_title",
"header_color_class",
"header_large",
"header_darken",
"header_cta_text",
"header_cta_buttons",
"header_cta_label",
"header_cta_link",
]

BUTTON_TYPE_CHOICES = (
("fr-btn", _("Primary")),
("fr-btn fr-btn--secondary", _("Secundary")),
Expand Down
Binary file modified content_manager/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading
Loading