Skip to content

Commit

Permalink
CONCD-675 pull content for Simple Page from the corresponding Guide (#…
Browse files Browse the repository at this point in the history
…2258)

* CONCD-675 pull content for Simple Page from the corresponding Guide section (rather than the reverse)

* CONCD-675 reverting older changes
  • Loading branch information
rasarkar authored Feb 5, 2024
1 parent 2f8830d commit fdb1dc5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion concordia/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ class SimplePageAdmin(admin.ModelAdmin):

fieldsets = (
(None, {"fields": ("created_on", "updated_on", "path", "title")}),
("Body", {"classes": ("markdown-preview",), "fields": ("navigation", "body")}),
("Body", {"classes": ("markdown-preview",), "fields": ("body",)}),
)


Expand Down
17 changes: 17 additions & 0 deletions concordia/migrations/0094_remove_simplepage_navigation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.23 on 2024-02-02 19:31

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("concordia", "0093_card_image_alt_text"),
]

operations = [
migrations.RemoveField(
model_name="simplepage",
name="navigation",
),
]
1 change: 0 additions & 1 deletion concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ class SimplePage(models.Model):

title = models.CharField(max_length=200)

navigation = models.TextField(null=True)
body = models.TextField()

def __str__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{{ block.super }}

<script>
setupCodeMirror(document.getElementById('id_navigation'), 'markdown');
setupCodeMirror(document.getElementById('id_body'), 'markdown');
</script>
{% endblock content %}
19 changes: 16 additions & 3 deletions concordia/templates/static-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@
<h1 class="my-3">{{ title }}</h1>

<div>
{% if nav %}
{% if add_navigation %}
<div class="row">
{{ nav|safe }}
{{ body|safe }}
<div class="col-3">
<div class="nav flex-column help-center">
<h4>Instructions</h4>
<a class="nav-link" href="/help-center/welcome-guide/">Get started</a>
<a class="nav-link" href="/help-center/how-to-transcribe/">How to transcribe</a>
<a class="nav-link{% if title == 'How to Review' %} active{% endif %}" href="/help-center/how-to-review/">How to review</a>
<a class="nav-link{% if title == 'How to Tag' %} active{% endif %}" href="/help-center/how-to-tag">How to tag</a>
<span lang="es">
<a class="nav-link" href="/help-center/how-to-transcribe-esp/">Instrucciones en español</a>
</span>
</div>
</div>
<div class="p-3 col-9">
{{ body|safe }}
</div>
</div>
{% else %}
{{ body|safe }}
Expand Down
12 changes: 8 additions & 4 deletions concordia/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def simple_page(request, path=None):
page = get_object_or_404(SimplePage, path=path)

md = markdown.Markdown(extensions=["meta"])
html = md.convert(page.body)

breadcrumbs = []
path_components = request.path.strip("/").split("/")
Expand All @@ -181,13 +180,18 @@ def simple_page(request, path=None):
language_code = "es"

ctx = {
"body": html,
"language_code": language_code,
"title": page.title,
"breadcrumbs": breadcrumbs,
}
if page.navigation is not None:
ctx["nav"] = md.convert(page.navigation)

guides = Guide.objects.filter(title__iexact=page.title)
if guides.count() > 0:
html = guides.first().body
ctx["add_navigation"] = True
else:
html = page.body
ctx["body"] = md.convert(html)

resp = render(request, "static-page.html", ctx)
resp["Created"] = http_date(page.created_on.timestamp())
Expand Down

0 comments on commit fdb1dc5

Please sign in to comment.