豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

TWO_FACTOR_SKIP_WELCOME setting to skip welcome page.#150

Open
stewbawka wants to merge 3 commits intomasterfrom
unknown repository
Open

TWO_FACTOR_SKIP_WELCOME setting to skip welcome page.#150
stewbawka wants to merge 3 commits intomasterfrom
unknown repository

Conversation

@stewbawka
Copy link
Copy Markdown

PR for issue #149
TWO_FACTOR_SKIP_WELCOME = True in settings will drop welcome page from wizard.
If setting is left out it will continue to work as normal.

Unit tests all passing.

@coveralls
Copy link
Copy Markdown

coveralls commented Jun 8, 2016

Coverage Status

Coverage decreased (-0.1%) to 95.587% when pulling 123bea3 on PACTAinc:wizard_skip_welcome_setting into 9ec5b1d on Bouke:master.

Comment thread two_factor/views/core.py Outdated
('yubikey', YubiKeyDeviceForm),
)
]
if hasattr(settings, 'TWO_FACTOR_SKIP_WELCOME') and settings.TWO_FACTOR_SKIP_WELCOME:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use condition_dict to skip certain wizard pages

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 7, 2016

Coverage Status

Coverage remained the same at 95.688% when pulling 4f13c24 on PACTAinc:wizard_skip_welcome_setting into 9ec5b1d on Bouke:master.

Comment thread two_factor/views/core.py
('yubikey', YubiKeyDeviceForm),
)

show_welcome = not hasattr(settings, 'TWO_FACTOR_SKIP_WELCOME') or not settings.TWO_FACTOR_SKIP_WELCOME
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be executed at import time, not when the lambda function in the condition_dict is being called. Can you either define the lambda expression here or move this into the lambda function's body, please.

Copy link
Copy Markdown

@pbassut pbassut Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just not getattr(settings, 'TWO_FACTOR_SKIP_WELCOME', False)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. because a definition of None in the settings is not the same as False.
  2. because it will still be executed at import time, not when it should be evaluated.

Copy link
Copy Markdown

@pbassut pbassut Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Change False to None then.
  2. What's the problem of being executed at import time? (don't know. actually curious)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's only evaluated once which makes testing harder. When you want to check for different values of TWO_FACTOR_SKIP_WELCOME you'd need to take care of that yourself. Using dynamic evaluation at runtime isn't much slower within this simple situation but makes testing easier.

@MarkusH
Copy link
Copy Markdown
Collaborator

MarkusH commented Jul 10, 2016

Apart from that, can you please add the settings to the documentation and add a test for this. Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants