#M00. As a User, I would like to register an account. - Auxfuse#83
Merged
stefdworschak merged 33 commits intoCode-Institute-Community:masterfrom Oct 21, 2020
auxfuse:user-auth-auxfuse
Merged
#M00. As a User, I would like to register an account. - Auxfuse#83stefdworschak merged 33 commits intoCode-Institute-Community:masterfrom auxfuse:user-auth-auxfuse
stefdworschak merged 33 commits intoCode-Institute-Community:masterfrom
auxfuse:user-auth-auxfuse
Conversation
…b/allauth package into root templates directory
…gnal as proof of concept
…e checks per explicit user type
…odel based on Sean Murphy code and help
…moved to lists.py and imported where necessary to reduce duplicate code fragments
…ci-hackathon-app into user-auth-auxfuse
stefdworschak
requested changes
Oct 20, 2020
Member
stefdworschak
left a comment
There was a problem hiding this comment.
@auxfuse really good pull request here and I do like the approach with the profile!
Just have a look at the comments below and let me know if you have any questions.
…registration and login to only reference email instead of username, and separated imports into 3rd party and local blocks
… per Django documentation and reflected email login use over username in str object
…itional trailing blank line to see if Github picks them up
Eventyret
reviewed
Oct 20, 2020
Eventyret
reviewed
Oct 20, 2020
Eventyret
reviewed
Oct 20, 2020
Eventyret
reviewed
Oct 20, 2020
…rmatter, adding appropriate indentation.
…y for increased code readability
…ormatted for increased code readability
…ensure industry best practice
…iles class save function accounts/models.py
Contributor
|
Nice thanks for adding docstrings @auxfuse LGTM 🥇 |
stefdworschak
approved these changes
Oct 21, 2020
Member
stefdworschak
left a comment
There was a problem hiding this comment.
LGTM
I don't want to hold this up any longer, but could you please raise a small follow-up PR for this? The follow-up PR should 1) add a line to log the exception you are catching in your Profile.save() and 2) add the links the auth pages (e.g. signup, login, etc) to the navbar menu. Thanks
1 task
stefdworschak
pushed a commit
that referenced
this pull request
Oct 21, 2020
This was referenced Oct 21, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR adds the ability for any type of user (participant, staff, admin) to use an extended Django allauth Signup Form to register onto the site.
Extending allauth Signup Form
Fields added to Signup Form:
Field autofocus reset added to set email as the default autofocus field on page load over username with custom logic to validate additional fields to the form listed above.
Profile Model Creation
Profile model created to host additional custom fields to be stored in the DB to match the additional fields added to the SignupForm, with a One-to-One relationship to the
AUTH_USER_MODEL. Profile Model includes save function to save via form/via the admin panel.user_signed_upsignal from allauth used to listen for user signup and then allow check on form fielduser_typeand the value selected by the user.User Type Logic:
is_activepermission flag in User object set to True and normal flow ensues.is_activepermission flag in User object set to False andis_staffpermission set to True, needing direct intervention from Site Administrator to Approve User before login onto the site can occur.is_activepermission flag in User object set to False andis_staff/is_superuserpermissions set to True, needing direct intervention from Site Administrator to Approve User before login onto the site/admin panel can occur.Additonal functionality includes backwards deletion of a User from Profile >> User Model using
post_deletesignal and using theProfilemodel as the default sender.Testing:
All testing was done manually throughout per user_type.
Screenshots:
See below gif of a user signup, selecting Staff as their account type, and a demonstration of checking the user
is_activepermission boolean in the admin panel to show the approval flow has worked.Additional Information:
When attempting to return the Profile Model data to the Profile.html template, the developer will need to decalre the expression as
{{ user.profile.<<field_name>> }}where<<field_name>>could equaluser_typefor example. See additional screenshot.Sean Murphy helped me immensly in understanding the required steps to access the form values for the Approval flow to work. Also assisted in providing the code for the Profile Model and Admin definition for same, including sitting in on calls and continuing to work on the project in tandem to my learning whilst implementing multiple experimental solutions, and even outside of my development hours. Man's a legend!