forked from AFPy/PonyConf
hide transport means if transport not requested
This commit is contained in:
parent
7dd687594b
commit
21c6812433
|
@ -19,9 +19,13 @@
|
|||
{% avatar request.user %}
|
||||
<a href="{% url 'avatar_change' %}" class="btn btn-default">{% trans "Change avatar" %}</a>
|
||||
</div>
|
||||
{% for form in forms %}
|
||||
{% bootstrap_form form layout="horizontal" %}
|
||||
{% endfor %}
|
||||
{% bootstrap_form user_form layout="horizontal" %}
|
||||
{% bootstrap_form profile_form layout="horizontal" %}
|
||||
{% 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" %}
|
||||
<button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
|
||||
{% for url, class, text in buttons %}
|
||||
|
@ -43,4 +47,17 @@
|
|||
{% block js_end %}
|
||||
{{ block.super }}
|
||||
{{ 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 %}
|
||||
|
|
|
@ -20,10 +20,11 @@ CHANGE_AVATAR_BUTTON = ('avatar_change', 'default', _('Change avatar'))
|
|||
@login_required
|
||||
def profile(request):
|
||||
|
||||
forms = [UserForm(request.POST or None, instance=request.user),
|
||||
ProfileForm(request.POST or None, instance=request.user.profile),
|
||||
ParticipationForm(request.POST or None, instance=Participation.objects.get(site=get_current_site(request),
|
||||
user=request.user))]
|
||||
user_form = UserForm(request.POST or None, instance=request.user)
|
||||
profile_form = ProfileForm(request.POST or None, instance=request.user.profile)
|
||||
participation_form = ParticipationForm(request.POST or None, instance=Participation.objects.get(site=get_current_site(request),
|
||||
user=request.user))
|
||||
forms = [user_form, profile_form, participation_form]
|
||||
|
||||
if request.method == 'POST':
|
||||
if all(form.is_valid() for form in forms):
|
||||
|
@ -33,7 +34,12 @@ def profile(request):
|
|||
else:
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user