Merge "Allow forms to disable autofill in all browsers"

This commit is contained in:
Jenkins 2014-09-04 10:12:20 +00:00 committed by Gerrit Code Review
commit e2cf3dcfc2
2 changed files with 10 additions and 1 deletions

View File

@ -14,12 +14,19 @@
<form id="{% block form_id %}{% endblock %}"
ng-controller="{% block ng_controller %}DummyCtrl{% endblock %}"
name="{% block form_name %}{% endblock %}"
autocomplete="{% block autocomplete %}{% endblock %}"
autocomplete="{% block autocomplete %}{% if form.no_autocomplete %}off{% endif %}{% endblock %}"
class="{% block form_class %}{% endblock %}"
action="{% block form_action %}{% endblock %}"
method="{% block form-method %}POST{% endblock %}"
{% if add_to_field %}data-add-to-field="{{ add_to_field }}"{% endif %} {% block form_attrs %}{% endblock %}>{% csrf_token %}
<div class="modal-body clearfix">
{% comment %}
These fake fields are required to prevent Chrome v34+ from autofilling form.
{% endcomment %}
{% if form.no_autocomplete %}
<input type="text" name="fake_email" value="" style="display: none" />
<input type="password" name="fake_password" value="" style="display: none" />
{% endif %}
{% block modal-body %}
<fieldset>
{% include "horizon/common/_form_fields.html" %}

View File

@ -95,6 +95,7 @@ class CreateUserForm(BaseUserForm):
add_item_link=ADD_PROJECT_URL)
role_id = forms.ChoiceField(label=_("Role"),
required=PROJECT_REQUIRED)
no_autocomplete = True
def __init__(self, *args, **kwargs):
roles = kwargs.pop('roles')
@ -173,6 +174,7 @@ class UpdateUserForm(BaseUserForm):
required=False)
project = forms.ChoiceField(label=_("Primary Project"),
required=PROJECT_REQUIRED)
no_autocomplete = True
def __init__(self, request, *args, **kwargs):
super(UpdateUserForm, self).__init__(request, *args, **kwargs)