Moving login error messages into the login dialog.

Fixing broken test and removing duplicate tenant_delete function.

Change-Id: I1dd20221c0ca4155e1005e229d70aeffc76bd633
This commit is contained in:
Tres Henry 2011-12-04 18:11:05 -08:00
parent 72ec279979
commit 6434611696
6 changed files with 20 additions and 15 deletions

View File

@ -141,10 +141,6 @@ def tenant_update(request, tenant_id, tenant_name, description, enabled):
enabled))
def tenant_delete(request, tenant_id):
keystoneclient(request).tenants.delete(tenant_id)
def tenant_list_for_token(request, token, endpoint_type=None):
c = keystoneclient(request,
token_id=token,

View File

@ -7,6 +7,14 @@
{% block form-action %}{% url horizon:auth_login %}{% endblock %}
{% block modal-body %}
{% for message in messages %}
{% if message.tags == "login error" %}
<div class="alert-message error">
<strong>{% trans "Error: " %}</strong>
{{ message }}
</div>
{% endif %}
{% endfor %}
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>

View File

@ -78,7 +78,9 @@ class AuthViewTests(test.BaseViewTests):
AndReturn([])
self.mox.StubOutWithMock(messages, 'error')
messages.error(IsA(http.HttpRequest), IsA(unicode))
messages.error(IsA(http.HttpRequest),
IsA(unicode),
extra_tags=IsA(str))
self.mox.ReplayAll()

View File

@ -20,12 +20,9 @@
import logging
from django.conf import settings
from django import template
from django import shortcuts
from django.contrib import messages
from django.utils.translation import ugettext as _
from openstackx.api import exceptions as api_exceptions
from horizon import api
from horizon import exceptions

View File

@ -87,7 +87,8 @@ class Login(forms.SelfHandlingForm):
data['username'],
data['password'])
except keystone_exceptions.Unauthorized:
messages.error(request, _('Bad user name or password.'))
messages.error(request, _('Bad user name or password.'),
extra_tags="login")
return
# Unscoped token
@ -102,7 +103,8 @@ class Login(forms.SelfHandlingForm):
if not tenants:
messages.error(request,
_('No tenants present for user: %(user)s') %
{"user": data['username']})
{"user": data['username']},
extra_tags="login")
return
# Create a token.
@ -130,11 +132,11 @@ class Login(forms.SelfHandlingForm):
except api_exceptions.Unauthorized as e:
msg = _('Error authenticating: %s') % e.message
LOG.exception(msg)
messages.error(request, msg)
messages.error(request, msg, extra_tags="login")
except api_exceptions.ApiException as e:
messages.error(request,
_('Error authenticating with keystone: %s') %
e.message)
e.message, extra_tags="login")
class LoginWithTenant(Login):

View File

@ -1,7 +1,7 @@
{% load i18n %}
{% for message in messages %}
{% if message.tags == "info" %}
<div class="alert-message info">
<div class="alert-message info">
<p><strong>{% trans "Info: " %}</strong>{{ message }}</p>
</div>
{% endif %}
@ -11,12 +11,12 @@
</div>
{% endif %}
{% if message.tags == "success" %}
<div class="alert-message success">
<div class="alert-message success">
<p><strong>{% trans "Success: " %}</strong>{{ message }}</p>
</div>
{% endif %}
{% if message.tags == "error" %}
<div class="alert-message error">
<div class="alert-message error">
<p><strong>{% trans "Error: " %}</strong>{{ message }}</p>
</div>
{% endif %}