[openstack-dev] [Horizon] Email as User Name on the Horizon login page

Adrian Turjak adriant at catalyst.net.nz
Sun Jan 17 21:38:03 UTC 2016


Updating the label code in django_openstack_auth isn't an option since
it would mean forking and maintaining our own copy of the library for
most likely one line of code.

Diana, any clue how would I go about overriding the label solely with
code placed in Horizon? Ideally we'd like to just place this in our own
theme to make rebasing horizon changes easier, but if needed we can live
with making this a non-theme patch for us to carry.

No clue how much we care about Localization, but if the answer is that
we do, how much work do you think adding "Email" to our Horizon
Localization would be?

Cheers,
-Adrian

On 16/01/16 07:43, Diana Whitten wrote:
> Adrian,
> 
> Changing the label is also possible through overrides, but customizing any
> label that goes through Localization might affect other languages.  Not
> sure if this might be a problem for you.
> 
> If this isn't ideal, we can easily put in hooks to allow customization
> purely through CSS, using pseudo selectors like ':before' or ':after' in
> combination with 'content'.  We just need to wrap the contents of the label
> with an inner span.
> 
> Thoughts?
> 
> - Diana
> 
> 
> 
> On Fri, Jan 15, 2016 at 10:47 AM, Lin Hua Cheng <os.lcheng at gmail.com> wrote:
> 
>> It might be simpler to just update the label on the python code. This is
>> where the form label are defined.
>>
>> You can update the label here:
>> https://github.com/openstack/django_openstack_auth/blob/stable/kilo/openstack_auth/forms.py#L51
>>
>> -Lin
>>
>>
>> On Fri, Jan 15, 2016 at 12:54 AM, Itxaka Serrano Garcia <itxaka at redhat.com
>>> wrote:
>>
>>>
>>> Looks like the form comes from django_openstack_auth:
>>>
>>> https://github.com/openstack/django_openstack_auth/blob/master/openstack_auth/forms.py#L53
>>>
>>>
>>> But to be honest, no idea how that can be overridden trough the themes,
>>> not sure if its even possible to override anything on that page without
>>> modifying django_openstack_auth directly :(
>>>
>>> Maybe someone else has a better insight on this than me.
>>>
>>>
>>> * Horrible Hack Incoming, read at your own discretion *
>>>
>>> You can override the template here:
>>>
>>> https://github.com/openstack/horizon/blob/master/horizon/templates/horizon/common/_form_field.html#L51
>>>
>>> And change this line:
>>> <label class="control-label {{ classes.label }} {% if
>>> field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{
>>> field.auto_id }}">{{ field.label }}</label>
>>>
>>> For this:
>>> <label class="control-label {{ classes.label }} {% if
>>> field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{
>>> field.auto_id }}">{% if field.label == "User Name" and not
>>> request.user.is_authenticated %}Email{% else %}{{ field.label }}{% endif
>>> %}</label>
>>>
>>>
>>> Which will check if the label is "User Name" and the user is logged out
>>> and directly write "Email" as the field label.
>>>
>>> I know, its horrible and if you update horizon it will be overriden, but
>>> probably works for the time being if you really need it ¯\_(ツ)_/¯
>>>
>>> * Horrible Hack Finished *
>>>
>>>
>>>
>>>
>>> Itxaka
>>>
>>>
>>>
>>>
>>>
>>> On 01/15/2016 05:13 AM, Adrian Turjak wrote:
>>>
>>>> I've run into a weird issue with the Liberty release of Horizon.
>>>>
>>>> For our deployment we enforce emails as usernames, and thus for Horizon
>>>> we used to have "User Name" on the login page replaced with "Email".
>>>> This used to be a straightforward change in the html template file, and
>>>> with the introduction of themes we assumed it would be the same. When
>>>> one of our designers was migrating our custom CSS and html changes to
>>>> the new theme system they missed that change and I at first it was a
>>>> silly mistake.
>>>>
>>>> Only on digging through the code myself I found that the "User Name" on
>>>> the login screen isn't in the html file at all, nor anywhere else
>>>> straightforward. The login page form is built on the fly with javascript
>>>> to facilitate different modes of authentication. While a bit annoying
>>>> that didn't seem too bad and I then assumed it might mean a javascript
>>>> change, only that the more I dug, the more I became confused.
>>>>
>>>> Where exactly is the login form defined? And where exactly is the "User
>>>> Name" text for the login form set?
>>>>
>>>> I've tried all manner of stuff to change it with no luck and I feel like
>>>> I must have missed something obvious.
>>>>
>>>> Cheers,
>>>> -Adrian Turjak
>>>>
>>>>
>>>> __________________________________________________________________________
>>>> OpenStack Development Mailing List (not for usage questions)
>>>> Unsubscribe:
>>>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>>>
>>>>
>>> __________________________________________________________________________
>>> OpenStack Development Mailing List (not for usage questions)
>>> Unsubscribe:
>>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>>
>>
>>
>> __________________________________________________________________________
>> OpenStack Development Mailing List (not for usage questions)
>> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
> 
> 
> 
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> 



More information about the OpenStack-dev mailing list