refactor(feedback): get party info from pages
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
62f470a0d6
commit
583a70b2c8
|
@ -3,17 +3,15 @@
|
||||||
{% block title %}Danke :){% endblock %}
|
{% block title %}Danke :){% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content">
|
{% if party_info %}
|
||||||
<h3>Randdaten zum Helfer*innen-Fest</h3>
|
{% autoescape off %}
|
||||||
<ul>
|
{{ party_info }}
|
||||||
<li><strong>Wo?</strong> Auf dem Festivalgelände</li>
|
{% endautoescape %}
|
||||||
<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>
|
|
||||||
<hr>
|
<hr>
|
||||||
|
{% endif %}
|
||||||
<div class="content">
|
<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>
|
</div>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
|
@ -3,6 +3,7 @@ from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
|
||||||
from shiftregister.app.models import LoginToken
|
from shiftregister.app.models import LoginToken
|
||||||
|
from shiftregister.pages.models import Page
|
||||||
|
|
||||||
from .forms import FeedbackForm
|
from .forms import FeedbackForm
|
||||||
from .models import Feedback, ShareToken
|
from .models import Feedback, ShareToken
|
||||||
|
@ -31,7 +32,11 @@ def feedback(request, token):
|
||||||
"Deine Angaben wurden gespeichert.",
|
"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
|
@login_required
|
||||||
|
|
|
@ -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>
|
|
@ -11,25 +11,35 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--force",
|
"-f", "--force", action="store_true", help="Always overwrite content"
|
||||||
action="store_true",
|
|
||||||
help="Always overwrite content",
|
|
||||||
)
|
)
|
||||||
|
parser.add_argument("pages", help="Specify which pages to import", nargs="*")
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
content_path = Path(__file__).resolve().parent.parent.parent / "default_content"
|
content_path = Path(__file__).resolve().parent.parent.parent / "default_content"
|
||||||
for file in content_path.iterdir():
|
for file in content_path.iterdir():
|
||||||
|
if (pages := options["pages"]) and file.stem not in pages:
|
||||||
|
continue
|
||||||
|
|
||||||
slug = file.stem
|
slug = file.stem
|
||||||
p, created = Page.objects.get_or_create(url=slug)
|
p, created = Page.objects.get_or_create(url=slug)
|
||||||
if (not created) and (not options["force"]):
|
if (not created) and (not options["force"]):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
soup = BeautifulSoup(file.read_text(), "html.parser")
|
soup = BeautifulSoup(file.read_text(), "html.parser")
|
||||||
|
|
||||||
if soup.title:
|
if soup.title:
|
||||||
p.title = soup.title.string
|
p.title = soup.title.string
|
||||||
soup.title.decompose()
|
soup.title.decompose()
|
||||||
else:
|
else:
|
||||||
p.title = slug.title()
|
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.content = str(soup).strip()
|
||||||
p.save()
|
p.save()
|
||||||
print(f'created new page "{p.title}" for slug {slug}')
|
print(f'created new page "{p.title}" for slug {slug}')
|
||||||
|
|
Loading…
Reference in New Issue