Skip to content

Commit

Permalink
Moving login error messages into the login dialog.
Browse files Browse the repository at this point in the history
Fixing broken test and removing duplicate tenant_delete function.

Change-Id: I1dd20221c0ca4155e1005e229d70aeffc76bd633
  • Loading branch information
treshenry committed Dec 6, 2011
1 parent 72ec279 commit 6434611
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
4 changes: 0 additions & 4 deletions horizon/horizon/api/keystone.py
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions horizon/horizon/templates/horizon/auth/_login.html
Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion horizon/horizon/tests/auth_tests.py
Expand Up @@ -78,7 +78,9 @@ class FakeToken(object):
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()

Expand Down
3 changes: 0 additions & 3 deletions horizon/horizon/views/auth.py
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions horizon/horizon/views/auth_forms.py
Expand Up @@ -87,7 +87,8 @@ def handle(self, request, data):
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
Expand All @@ -102,7 +103,8 @@ def handle(self, request, data):
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.
Expand Down Expand Up @@ -130,11 +132,11 @@ def handle(self, request, data):
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):
Expand Down
6 changes: 3 additions & 3 deletions openstack-dashboard/dashboard/templates/_messages.html
@@ -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 %}
Expand All @@ -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 %}
Expand Down

0 comments on commit 6434611

Please sign in to comment.