From 28634840d5f0e1b0a6a61412bdf40836b92b5943 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter <lucas@brandstaetter.tech> Date: Mon, 25 Dec 2023 11:55:04 +0100 Subject: [PATCH] Add template form for links --- src/backoffice/templates/backoffice/base.html | 4 ++++ .../templates/backoffice/link/components/form_line.html | 2 ++ .../templates/backoffice/link/link_display.html | 3 +-- .../templates/backoffice/project/create_edit.html | 8 ++++++++ src/backoffice/views/projects.py | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/backoffice/templates/backoffice/link/components/form_line.html diff --git a/src/backoffice/templates/backoffice/base.html b/src/backoffice/templates/backoffice/base.html index 20517eae6..6d8d7f318 100644 --- a/src/backoffice/templates/backoffice/base.html +++ b/src/backoffice/templates/backoffice/base.html @@ -262,5 +262,9 @@ </div> </div> </div> + <div class="d-none" id="templates"> + {% block templates %} + {% endblock templates %} + </div> </body> </html> diff --git a/src/backoffice/templates/backoffice/link/components/form_line.html b/src/backoffice/templates/backoffice/link/components/form_line.html new file mode 100644 index 000000000..e927debde --- /dev/null +++ b/src/backoffice/templates/backoffice/link/components/form_line.html @@ -0,0 +1,2 @@ +{% load django_bootstrap5 %} +<div class="row row-cols-lg-auto g-3 align-items-center">{% bootstrap_form link_form layout='inline' %}</div> diff --git a/src/backoffice/templates/backoffice/link/link_display.html b/src/backoffice/templates/backoffice/link/link_display.html index d461270e7..375cedb7d 100644 --- a/src/backoffice/templates/backoffice/link/link_display.html +++ b/src/backoffice/templates/backoffice/link/link_display.html @@ -1,7 +1,6 @@ {% load django_bootstrap5 %} {% load i18n %} - <div class="card-header bg-default">{% trans 'Links' %}</div> <ul class="list-group list-group-flush"> {% csrf_token %} @@ -10,7 +9,7 @@ {% bootstrap_formset_errors link_forms layout='inline' %} {% for link_form in link_forms %} <li class="list-group-item"> - <div class="row row-cols-lg-auto g-3 align-items-center">{% bootstrap_form link_form layout='inline' %}</div> + {% include 'backoffice/link/components/form_line.html' %} </li> {% endfor %} </ul> diff --git a/src/backoffice/templates/backoffice/project/create_edit.html b/src/backoffice/templates/backoffice/project/create_edit.html index 39599160e..5d60767dd 100644 --- a/src/backoffice/templates/backoffice/project/create_edit.html +++ b/src/backoffice/templates/backoffice/project/create_edit.html @@ -167,3 +167,11 @@ </div> {% endif %} {% endblock content %} + +{% block templates %} +<div id="link_form_template"> + {% with link_form=template_link_form %} + {% include 'backoffice/link/components/form_line.html' %} + {% endwith %} +</div> +{% endblock templates %} \ No newline at end of file diff --git a/src/backoffice/views/projects.py b/src/backoffice/views/projects.py index f445c4b81..e5e85fd5b 100644 --- a/src/backoffice/views/projects.py +++ b/src/backoffice/views/projects.py @@ -123,6 +123,7 @@ class ProjectFormMixin(ConferenceRequiredMixin, FormView): def get_context_data(self, *args, **kwargs): ctx = super().get_context_data(*args, **kwargs) + ctx['template_link_form'] = LinkForm(prefix='template') if 'form' not in kwargs: ctx['form'] = self.get_form() if 'link_forms' not in kwargs: -- GitLab