hide transport means if transport not requested
This commit is contained in:
parent
7dd687594b
commit
21c6812433
|
@ -19,9 +19,13 @@
|
||||||
{% avatar request.user %}
|
{% avatar request.user %}
|
||||||
<a href="{% url 'avatar_change' %}" class="btn btn-default">{% trans "Change avatar" %}</a>
|
<a href="{% url 'avatar_change' %}" class="btn btn-default">{% trans "Change avatar" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% for form in forms %}
|
{% bootstrap_form user_form layout="horizontal" %}
|
||||||
{% bootstrap_form form layout="horizontal" %}
|
{% bootstrap_form profile_form layout="horizontal" %}
|
||||||
{% endfor %}
|
{% bootstrap_field participation_form.need_transport layout="horizontal" %}
|
||||||
|
<div id="transport_field">
|
||||||
|
{% bootstrap_field participation_form.transport layout="horizontal" %}
|
||||||
|
</div>
|
||||||
|
{% bootstrap_form participation_form exclude="need_transport,transport" layout="horizontal" %}
|
||||||
{% buttons layout="horizontal" %}
|
{% buttons layout="horizontal" %}
|
||||||
<button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
|
<button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
|
||||||
{% for url, class, text in buttons %}
|
{% for url, class, text in buttons %}
|
||||||
|
@ -43,4 +47,17 @@
|
||||||
{% block js_end %}
|
{% block js_end %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var update_transport = function() {
|
||||||
|
if ($('#id_need_transport').val() == 2) { // 2 == 'Yes'
|
||||||
|
$("#transport_field").show();
|
||||||
|
} else {
|
||||||
|
$("#transport_field").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(function(){
|
||||||
|
update_transport();
|
||||||
|
$('#id_need_transport').change(update_transport);
|
||||||
|
})
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -20,10 +20,11 @@ CHANGE_AVATAR_BUTTON = ('avatar_change', 'default', _('Change avatar'))
|
||||||
@login_required
|
@login_required
|
||||||
def profile(request):
|
def profile(request):
|
||||||
|
|
||||||
forms = [UserForm(request.POST or None, instance=request.user),
|
user_form = UserForm(request.POST or None, instance=request.user)
|
||||||
ProfileForm(request.POST or None, instance=request.user.profile),
|
profile_form = ProfileForm(request.POST or None, instance=request.user.profile)
|
||||||
ParticipationForm(request.POST or None, instance=Participation.objects.get(site=get_current_site(request),
|
participation_form = ParticipationForm(request.POST or None, instance=Participation.objects.get(site=get_current_site(request),
|
||||||
user=request.user))]
|
user=request.user))
|
||||||
|
forms = [user_form, profile_form, participation_form]
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if all(form.is_valid() for form in forms):
|
if all(form.is_valid() for form in forms):
|
||||||
|
@ -33,7 +34,12 @@ def profile(request):
|
||||||
else:
|
else:
|
||||||
messages.error(request, 'Please correct those errors.')
|
messages.error(request, 'Please correct those errors.')
|
||||||
|
|
||||||
return render(request, 'accounts/profile.html', {'forms': forms, 'buttons': [CHANGE_PASSWORD_BUTTON]})
|
return render(request, 'accounts/profile.html', {
|
||||||
|
'user_form': user_form,
|
||||||
|
'profile_form': profile_form,
|
||||||
|
'participation_form': participation_form,
|
||||||
|
'buttons': [CHANGE_PASSWORD_BUTTON]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@staff_required
|
@staff_required
|
||||||
|
|
Loading…
Reference in New Issue
Block a user