2
0
Fork 0

refactor(feedback): get party info from pages
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2024-05-27 17:58:37 +02:00
parent 62f470a0d6
commit 583a70b2c8
4 changed files with 35 additions and 13 deletions

View File

@ -3,17 +3,15 @@
{% block title %}Danke :){% endblock %}
{% block content %}
<div class="content">
<h3>Randdaten zum Helfer*innen-Fest</h3>
<ul>
<li><strong>Wo?</strong> Auf dem Festivalgelände</li>
<li><strong>Wann?</strong> Samstag, 3.6. um 17 Uhr</li>
<li><strong>Was?</strong> Fleischfreies Grillen (Alle bringen was mit), Getränke gehen auf uns und Musik haben wir.</li>
</ul>
</div>
{% if party_info %}
{% autoescape off %}
{{ party_info }}
{% endautoescape %}
<hr>
{% endif %}
<div class="content">
Bitte teil uns hierüber mit, ob du kommst. Vergiss nicht, deine Angaben mit dem <strong>Speichern</strong>-Button unten abzuschicken.
Bitte teil uns hierüber mit, ob du zum Helfer*innen-Fest kommst.
Vergiss nicht, deine Angaben mit dem <strong>Speichern</strong>-Button unten abzuschicken.
</div>
<form action="" method="post">
{% csrf_token %}

View File

@ -3,6 +3,7 @@ from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render
from shiftregister.app.models import LoginToken
from shiftregister.pages.models import Page
from .forms import FeedbackForm
from .models import Feedback, ShareToken
@ -31,7 +32,11 @@ def feedback(request, token):
"Deine Angaben wurden gespeichert.",
)
return render(request, "feedback.html", {"form": form})
party_info = None
if p := Page.objects.filter(title__iexact="party", kind=Page.REGULAR).first():
party_info = p.content
return render(request, "feedback.html", {"form": form, "party_info": party_info})
@login_required

View File

@ -0,0 +1,9 @@
<meta name="visible" content="no">
<div class="content">
<h3>Randdaten zum Helfer*innen-Fest</h3>
<ul>
<li><strong>Wo?</strong> Auf dem Festivalgelände</li>
<li><strong>Wann?</strong> Samstag, TBD um 17 Uhr</li>
<li><strong>Was?</strong> Fleischfreies Grillen (Alle bringen was mit), Getränke gehen auf uns und Musik haben wir</li>
</ul>
</div>

View File

@ -11,25 +11,35 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
"--force",
action="store_true",
help="Always overwrite content",
"-f", "--force", action="store_true", help="Always overwrite content"
)
parser.add_argument("pages", help="Specify which pages to import", nargs="*")
def handle(self, *args, **options):
content_path = Path(__file__).resolve().parent.parent.parent / "default_content"
for file in content_path.iterdir():
if (pages := options["pages"]) and file.stem not in pages:
continue
slug = file.stem
p, created = Page.objects.get_or_create(url=slug)
if (not created) and (not options["force"]):
continue
soup = BeautifulSoup(file.read_text(), "html.parser")
if soup.title:
p.title = soup.title.string
soup.title.decompose()
else:
p.title = slug.title()
if visible := soup.find("meta", attrs={"name": "visible"}):
p.visible = "content" not in visible.attrs or visible.attrs[
"content"
].lower() in ("1", "true", "yes")
visible.decompose()
p.content = str(soup).strip()
p.save()
print(f'created new page "{p.title}" for slug {slug}')