forked from mirrors/bookwyrm
Fixes default values in edit announcement form
This commit is contained in:
parent
8b6934d1d0
commit
a70c713c29
2 changed files with 8 additions and 3 deletions
|
@ -2,7 +2,11 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
|
{% if announcement %}
|
||||||
|
{% trans "Edit Announcement" %}
|
||||||
|
{% else %}
|
||||||
{% trans "Create Announcement" %}
|
{% trans "Create Announcement" %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block form %}
|
{% block form %}
|
||||||
|
@ -24,7 +28,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label class="label" for="id_event_date">Event date:</label>
|
<label class="label" for="id_event_date">Event date:</label>
|
||||||
<input type="date" name="event_date" value="{{ form.event_date.value }}" class="input" id="id_event_date">
|
<input type="date" name="event_date" value="{{ form.event_date.value|date:'Y-m-d' }}" class="input" id="id_event_date">
|
||||||
{% for error in form.event_date.errors %}
|
{% for error in form.event_date.errors %}
|
||||||
<p class="help is-danger">{{ error | escape }}</p>
|
<p class="help is-danger">{{ error | escape }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -34,7 +38,7 @@
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<p>
|
<p>
|
||||||
<label class="label" for="id_start_date">Start date:</label>
|
<label class="label" for="id_start_date">Start date:</label>
|
||||||
<input type="date" name="start_date" class="input" id="id_start_date">
|
<input type="date" name="start_date" class="input" value="{{ form.start_date.value|date:'Y-m-d' }}" id="id_start_date">
|
||||||
{% for error in form.start_date.errors %}
|
{% for error in form.start_date.errors %}
|
||||||
<p class="help is-danger">{{ error | escape }}</p>
|
<p class="help is-danger">{{ error | escape }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -43,7 +47,7 @@
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<p>
|
<p>
|
||||||
<label class="label" for="id_end_date">End date:</label>
|
<label class="label" for="id_end_date">End date:</label>
|
||||||
<input type="date" name="end_date" class="input" id="id_end_date">
|
<input type="date" name="end_date" class="input" id="id_end_date" value="{{ form.end_date.value|date:'Y-m-d' }}">
|
||||||
{% for error in form.end_date.errors %}
|
{% for error in form.end_date.errors %}
|
||||||
<p class="help is-danger">{{ error | escape }}</p>
|
<p class="help is-danger">{{ error | escape }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Announcement(View):
|
||||||
form = forms.AnnouncementForm(request.POST, instance=announcement)
|
form = forms.AnnouncementForm(request.POST, instance=announcement)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
announcement = form.save()
|
announcement = form.save()
|
||||||
|
form = forms.AnnouncementForm(instance=announcement)
|
||||||
data = {
|
data = {
|
||||||
"announcement": announcement,
|
"announcement": announcement,
|
||||||
"form": form,
|
"form": form,
|
||||||
|
|
Loading…
Reference in a new issue