-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restarting to work on that functionality
- Loading branch information
Showing
5 changed files
with
260 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Generated by Django 5.0.6 on 2024-06-24 14:34 | ||
|
||
import django.db.models.deletion | ||
import modelcluster.fields | ||
import wagtail.contrib.forms.models | ||
import wagtail.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("content_manager", "0034_alter_contentpage_body"), | ||
("wagtailcore", "0093_uploadedfile"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="FormPage", | ||
fields=[ | ||
( | ||
"page_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="wagtailcore.page", | ||
), | ||
), | ||
( | ||
"to_address", | ||
models.CharField( | ||
blank=True, | ||
help_text="Optional - form submissions will be emailed to these addresses. Separate multiple addresses by comma.", | ||
max_length=255, | ||
validators=[wagtail.contrib.forms.models.validate_to_address], | ||
verbose_name="to address", | ||
), | ||
), | ||
("from_address", models.EmailField(blank=True, max_length=255, verbose_name="from address")), | ||
("subject", models.CharField(blank=True, max_length=255, verbose_name="subject")), | ||
("intro", wagtail.fields.RichTextField(blank=True)), | ||
("thank_you_text", wagtail.fields.RichTextField(blank=True)), | ||
], | ||
options={ | ||
"verbose_name": "Page de formulaire", | ||
"verbose_name_plural": "Pages de formulaire", | ||
}, | ||
bases=(wagtail.contrib.forms.models.FormMixin, "wagtailcore.page", models.Model), | ||
), | ||
migrations.CreateModel( | ||
name="FormField", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("sort_order", models.IntegerField(blank=True, editable=False, null=True)), | ||
( | ||
"clean_name", | ||
models.CharField( | ||
blank=True, | ||
default="", | ||
help_text="Safe name of the form field, the label converted to ascii_snake_case", | ||
max_length=255, | ||
verbose_name="name", | ||
), | ||
), | ||
( | ||
"label", | ||
models.CharField(help_text="The label of the form field", max_length=255, verbose_name="label"), | ||
), | ||
( | ||
"field_type", | ||
models.CharField( | ||
choices=[ | ||
("singleline", "Single line text"), | ||
("multiline", "Multi-line text"), | ||
("email", "Email"), | ||
("number", "Number"), | ||
("url", "URL"), | ||
("checkbox", "Checkbox"), | ||
("checkboxes", "Checkboxes"), | ||
("dropdown", "Drop down"), | ||
("multiselect", "Multiple select"), | ||
("radio", "Radio buttons"), | ||
("date", "Date"), | ||
("datetime", "Date/time"), | ||
("hidden", "Hidden field"), | ||
], | ||
max_length=16, | ||
verbose_name="field type", | ||
), | ||
), | ||
("required", models.BooleanField(default=True, verbose_name="required")), | ||
( | ||
"choices", | ||
models.TextField( | ||
blank=True, | ||
help_text="Comma or new line separated list of choices. Only applicable in checkboxes, radio and dropdown.", | ||
verbose_name="choices", | ||
), | ||
), | ||
( | ||
"default_value", | ||
models.TextField( | ||
blank=True, | ||
help_text="Default value. Comma or new line separated values supported for checkboxes.", | ||
verbose_name="default value", | ||
), | ||
), | ||
("help_text", models.CharField(blank=True, max_length=255, verbose_name="help text")), | ||
( | ||
"page", | ||
modelcluster.fields.ParentalKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="form_fields", | ||
to="content_manager.formpage", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["sort_order"], | ||
"abstract": False, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "base.html" %} | ||
|
||
{% load wagtailcore_tags dsfr_tags %} | ||
|
||
{% block content %} | ||
<div class="fr-container fr-my-6w"> | ||
<div class="fr-grid-row fr-grid-row--center"> | ||
<div class="fr-col-md-8"> | ||
<h1>{{ page.title }}</h1> | ||
{{ page.intro|richtext }} | ||
<form action="{% pageurl page %}" method="post"> | ||
{% csrf_token %} | ||
{% dsfr_form %} | ||
<input class="fr-btn" type="submit"> | ||
<ul> | ||
{% for field in form %} | ||
<li>{{ field.label }}, {{ field.type }}, {{ field.field.widget.attrs }} {{ field.field.widget }}</li> | ||
{% endfor %} | ||
</ul> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
10 changes: 10 additions & 0 deletions
10
content_manager/templates/content_manager/form_page_landing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "base.html" %} | ||
|
||
{% load wagtailcore_tags %} | ||
|
||
{% block content %} | ||
<div class="fr-container fr-mt-6w"> | ||
<h1>{{ page.title }}</h1> | ||
{{ page.thank_you_text|richtext }} | ||
</div> | ||
{% endblock content %} |