Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TWO_FACTOR_SKIP_WELCOME setting to skip welcome page. #150

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

TWO_FACTOR_SKIP_WELCOME setting to skip welcome page. #150

wants to merge 3 commits into from

Conversation

stewbawka
Copy link

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

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.

('welcome', Form),
('method', MethodForm),
('generator', TOTPDeviceForm),
('sms', PhoneNumberForm),
('call', PhoneNumberForm),
('validation', DeviceValidationForm),
('yubikey', YubiKeyDeviceForm),
)
]
if hasattr(settings, 'TWO_FACTOR_SKIP_WELCOME') and settings.TWO_FACTOR_SKIP_WELCOME:
Copy link
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

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.

@@ -213,7 +213,10 @@ class SetupView(IdempotentSessionWizardView):
('validation', DeviceValidationForm),
('yubikey', YubiKeyDeviceForm),
)

show_welcome = not hasattr(settings, 'TWO_FACTOR_SKIP_WELCOME') or not settings.TWO_FACTOR_SKIP_WELCOME
Copy link
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

@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
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

@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
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
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