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

Check User model actually has fields for form Meta #1275

Conversation

alex-moon
Copy link
Contributor

This is necessary because the Meta def itself is sufficient to crash the app for a different User model - the form doesn't even need to be instantiated. There is still plenty more code that makes explicit reference to first_name and last_name however.

@maiksprenger
Copy link
Member

This probably isn't enough, as the tests don't pass locally (Travis already dies with the lint errors).

It's a bit odd because the password1 and password2 fields are not part of most User models.

fields = ('first_name', 'last_name', 'email', 'password1', 'password2')
# from Django 1.6 the User model can be overridden not to have these fields
# without the explicit check here this class def crashes the app
fields = [field for field in ['first_name', 'last_name', 'email', 'password1', 'password2'] if hasattr(User, field)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is completely incorrect in fact. User doesn't have fields as attributes.

@alex-moon alex-moon closed this in a32766b Apr 1, 2014
alex-moon pushed a commit that referenced this pull request Apr 1, 2014
This is necessary because the Meta def itself is sufficient to crash the
app for a different User model - the form doesn't even need to be
instantiated. There is still plenty more code that makes explicit
reference to first_name and last_name however.

Fixes #1275

Moved to oscar.core.compat and renamed by @maikhoepfel

Conflicts:
	oscar/apps/dashboard/partners/forms.py
	oscar/core/compat.py

Backport of a32766b.
@mbertheau mbertheau deleted the feature/1274_user_forms_meta_fields_for_different_user_model branch November 24, 2014 20:47
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.

None yet

2 participants