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

N'exporte (vraiment) que les containers ready_to_publish #6282

Merged
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
37 changes: 23 additions & 14 deletions templates/tutorialv2/export/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,59 @@
{% if intro.strip != '' %}

{{ intro }}
{% endif %}
{% endif %}
{% endif %} {# intro.strip != '' #}
{% endif %} {# content.introduction #}

{% for child in content.children %}
{% if child.ready_to_publish %}
{% if content.has_extracts or child.ready_to_publish %}
# {{ child.title|safe }}
{% if content.has_extracts %} {# minituto or article #}
{% if content.has_extracts %} {# minituto, article or opinion #}
{% if child.text %}{{ child.get_text|safe|shift_heading_1 }}{% endif %}
{% else %} {# midsize or bigtuto #}
{% elif child.ready_to_publish %} {# midsize or bigtuto #}
{% if child.introduction %}{{ child.get_introduction|safe|shift_heading_1 }}{% endif %}
{% for subchild in child.children %}
{% if subchild.ready_to_publish %}
{% if child.has_extracts or subchild.ready_to_publish %}
## {{ subchild.title|safe }}

{% if child.has_extracts %} {# midsize tuto #}
{% if subchild.text %}{{ subchild.get_text|safe|shift_heading_2 }}{% endif %}
{% else %} {# bigtuto #}
{% elif subchild.ready_to_publish %} {# bigtuto #}
{% if subchild.introduction %}{{ subchild.get_introduction|safe|shift_heading_2 }}{% endif %}
{% for extract in subchild.children %}

### {{ extract.title|safe }}

{% if extract.text %}{{ extract.get_text|safe|shift_heading_3 }}{% endif %}{% endfor %}
{% if extract.text %}{{ extract.get_text|safe|shift_heading_3 }}{% endif %}
{% endfor %} {# extract in subchild.children #}
{% if subchild.conclusion %}
{% captureas conclu %}{{ subchild.get_conclusion|safe|shift_heading_2 }}{% endcaptureas %}
{% if conclu.strip != '' %}
---------

{{ conclu }}{% endif %}{% endif %}
{% endif %}{% endif %}{% endfor %}
{{ conclu }}
{% endif %} {# conclu.strip != '' #}
{% endif %} {# subchild.conclusion #}
{% endif %} {# subchild.ready_to_publish #}
{% endif %} {# child.has_extracts or subchild.ready_to_publish #}
{% endfor %} {# subchild in child.children #}
{% if child.conclusion %}
{% captureas conclu %}{{ child.get_conclusion|safe|shift_heading_1 }}{% endcaptureas %}
{% if conclu.strip != '' %}
---------

{{ conclu }}{% endif %}{% endif %}
{% endif %}{% endif %}{% endfor %}
{{ conclu }}
{% endif %} {# conclu.strip != '' #}
{% endif %} {# child.conclusion #}
{% endif %} {# child.ready_to_publish #}
{% endif %} {# content.has_extracts or child.ready_to_publish #}
{% endfor %} {# child in content.children #}
{% if content.conclusion %}
{% captureas conclu %}{{ content.get_conclusion|safe }}{% endcaptureas %}
{% if conclu.strip != '' %}

---------

{{ conclu }}
{% endif %}
{% endif %}
{% endif %} {# conclu.strip != '' #}
{% endif %} {# content.conclusion #}
{% endautoescape %}
24 changes: 16 additions & 8 deletions zds/tutorialv2/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def _generate(cls, create, attrs):
if not light:
text = tricky_text_content

intro_content = attrs.pop("intro", text)
conclusion_content = attrs.pop("conclusion", text)

publishable_content = super()._generate(create, attrs)
publishable_content.gallery = GalleryFactory()
publishable_content.licence = licence
Expand All @@ -88,7 +91,7 @@ def _generate(cls, create, attrs):
for author in publishable_content.authors.all():
UserGalleryFactory(user=author, gallery=publishable_content.gallery, mode="W")

init_new_repo(publishable_content, text, text)
init_new_repo(publishable_content, intro_content, conclusion_content)

return publishable_content

Expand All @@ -114,14 +117,17 @@ def _generate(cls, create, attrs):
# which is why we use attrs.get() (it stays in attrs).
parent = attrs.get("parent", None)

# Needed because we use container.title later
container = super()._generate(create, attrs)

text = text_content
if not light:
text = tricky_text_content

sha = parent.repo_add_container(container.title, text, text)
intro_content = attrs.pop("intro", text)
conclusion_content = attrs.pop("conclusion", text)

# Needed because we use container.title later
container = super()._generate(create, attrs)

sha = parent.repo_add_container(container.title, intro_content, conclusion_content)
container = parent.children[-1]

if db_object:
Expand Down Expand Up @@ -152,13 +158,15 @@ def _generate(cls, create, attrs):
# which is why we use attrs.get() (it stays in attrs).
container = attrs.get("container", None)

text = text_content
if not light:
text = tricky_text_content
text = attrs.pop("text_content", text)

# Needed because we use extract.title later
extract = super()._generate(create, attrs)

parent = container
text = text_content
if not light:
text = tricky_text_content

sha = parent.repo_add_extract(extract.title, text)
extract = parent.children[-1]
Expand Down
Loading