forked from gergely/calendar-social
Add a field macro to the event creation form
This commit is contained in:
parent
a133218906
commit
d06cfaa02e
21
calsocial/templates/_macros.html
Normal file
21
calsocial/templates/_macros.html
Normal file
@ -0,0 +1,21 @@
|
||||
{% macro field(field, inline=false) %}
|
||||
{% if field.errors %}
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if field.widget.input_type != 'checkbox' %}
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
{{ field }}
|
||||
{% if field.widget.input_type == 'checkbox' %}
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
{% if not inline %}
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if field.description %}
|
||||
{{ field.description }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
@ -1,4 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
<h1>
|
||||
@ -28,9 +29,7 @@
|
||||
<form method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{{ form.invitee.errors }}
|
||||
{{ form.invitee.label }}
|
||||
{{ form.invitee}}
|
||||
{{ field(form.invitee, inline=true) }}
|
||||
|
||||
<button type="submit">{% trans %}Invite{% endtrans %}</button>
|
||||
</form>
|
||||
|
@ -1,41 +1,24 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Create event</h2>
|
||||
<form method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{{ form.errors }}
|
||||
{% if form.errors %}
|
||||
{% for error in form.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
<br>
|
||||
{% endif %}
|
||||
|
||||
{{ form.title.errors }}
|
||||
{{ form.title.label }}
|
||||
{{ form.title }}
|
||||
<br>
|
||||
|
||||
{{ form.time_zone.errors }}
|
||||
{{ form.time_zone.label }}
|
||||
{{ form.time_zone }}
|
||||
<br>
|
||||
|
||||
{{ form.start_time.errors }}
|
||||
{{ form.start_time.label }}
|
||||
{{ form.start_time }}
|
||||
<br>
|
||||
|
||||
{{ form.end_time.errors }}
|
||||
{{ form.end_time.label }}
|
||||
{{ form.end_time }}
|
||||
<br>
|
||||
|
||||
{{ form.all_day.errors }}
|
||||
{{ form.all_day.label }}
|
||||
{{ form.all_day }}
|
||||
<br>
|
||||
|
||||
{{ form.description.errors }}
|
||||
{{ form.description.label }}
|
||||
{{ form.description }}
|
||||
<br>
|
||||
{{ field(form.title) }}
|
||||
{{ field(form.time_zone) }}
|
||||
{{ field(form.start_time) }}
|
||||
{{ field(form.end_time) }}
|
||||
{{ field(form.all_day) }}
|
||||
{{ field(form.description) }}
|
||||
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
<a href="{{ url_for('hello') }}">Cancel</a>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans %}First steps{% endtrans %}</h1>
|
||||
@ -13,17 +14,10 @@
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<p>
|
||||
{{ form.display_name.errors }}
|
||||
{{ form.display_name.label }}
|
||||
{{ form.display_name }}<br>
|
||||
{{ form.display_name.description }}
|
||||
{{ field(form.display_name) }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ form.time_zone.errors }}
|
||||
{{ form.time_zone.label }}
|
||||
{{ form.time_zone }}<br>
|
||||
{{ form.time_zone.description }}
|
||||
{{ field(form.time_zone) }}
|
||||
</p>
|
||||
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% extends 'settings-base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
{{ super() }}
|
||||
@ -7,15 +8,8 @@
|
||||
{{ form.hidden_tag() }}
|
||||
{{ form.errors }}
|
||||
|
||||
{{ form.display_name.errors }}
|
||||
{{ form.display_name.label }}
|
||||
{{ form.display_name }}
|
||||
<br>
|
||||
|
||||
{{ form.locked.errors }}
|
||||
{{ form.locked.label }}
|
||||
{{ form.locked}}
|
||||
<br>
|
||||
{{ field(form.display_name) }}
|
||||
{{ field(form.locked) }}
|
||||
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
</form>
|
||||
|
@ -1,29 +1,15 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{{ form.errors }}
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{{ form.username.errors }}
|
||||
{{ form.username.label }}
|
||||
{{ form.username }}
|
||||
<br>
|
||||
|
||||
{{ form.email.errors }}
|
||||
{{ form.email.label }}
|
||||
{{ form.email }}
|
||||
<br>
|
||||
|
||||
{{ form.password.errors }}
|
||||
{{ form.password.label }}
|
||||
{{ form.password }}
|
||||
<br>
|
||||
|
||||
{{ form.password_retype.errors }}
|
||||
{{ form.password_retype.label }}
|
||||
{{ form.password_retype }}
|
||||
<br>
|
||||
{{ field(form.username) }}
|
||||
{{ field(form.email) }}
|
||||
{{ field(form.password) }}
|
||||
{{ field(form.password_retype) }}
|
||||
|
||||
<button type="submit">{% trans %}Register{% endtrans %}</button>
|
||||
</form>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% extends 'settings-base.html' %}
|
||||
{% from '_macros.html' import field %}
|
||||
|
||||
{% block content %}
|
||||
{{ super() }}
|
||||
@ -9,10 +10,7 @@
|
||||
{{ form.errors }}
|
||||
<br>
|
||||
|
||||
{{ form.timezone.errors }}
|
||||
{{ form.timezone.label }}
|
||||
{{ form.timezone}}
|
||||
<br>
|
||||
{{ field(form.timezone) }}
|
||||
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
<a href="{{ url_for('hello') }}">Cancel</a>
|
||||
|
Loading…
Reference in New Issue
Block a user