-
Notifications
You must be signed in to change notification settings - Fork 0
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
SS-643 Users can edit their account details #235
SS-643 Users can edit their account details #235
Conversation
Co-authored-by: Viktor Sandström <[email protected]>
This reverts commit d321a3f.
user_form_details = self.user_edit_form_class( | ||
request.POST, | ||
instance=request.user, | ||
initial={ | ||
"email": user_profile_data.user.email, | ||
}, | ||
) | ||
|
||
profile_form_details = self.profile_edit_form_class( | ||
request.POST, | ||
instance=user_profile_data, | ||
initial={ | ||
"affiliation": user_profile_data.affiliation, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure, that user cannot pass any other information in the form data.
For instance, that user via direct curl request cannot change their email or password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used decorator to ensure login-required in 'common/urls.py' and in 'EditProfileView' class in 'common/views.py'.
removed comments Co-authored-by: Nikita Churikov <[email protected]>
fixed the gap after hash sign Co-authored-by: Nikita Churikov <[email protected]>
changed the comment text Co-authored-by: Nikita Churikov <[email protected]>
common/urls.py
Outdated
@@ -9,5 +10,5 @@ | |||
path("success/", views.RegistrationCompleteView.as_view(), name="success"), | |||
path("signup/", views.SignUpView.as_view(), name="signup"), | |||
path("verify/", views.VerifyView.as_view(), name="verify"), | |||
path("edit-profile/", views.EditProfileView.as_view(), name="edit-profile"), | |||
path("edit-profile/", login_required(views.EditProfileView.as_view()), name="edit-profile"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you define login_required
here and in common/views.py
?
Just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make sure only logged-in user can access the view/form. I removed in the last commit.
common/views.py
Outdated
user_form_retrived_data.save() | ||
|
||
else: | ||
logger.info("Not saving user form info as nothing has changed", exc_info=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info("Not saving user form info as nothing has changed", exc_info=True) | |
logger.info("Not saving user form info as nothing has changed") |
Correct me if I'm wrong, but I don't think that exc_info
needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I removed it.
common/views.py
Outdated
user_form_retrived_data.password1 = user_profile_data.user.password | ||
user_form_retrived_data.password2 = user_profile_data.user.password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully get it, why are we doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to save only the new information. I removed it, as I checked the the previous way is okay to prevent the curl injection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've submitted a few code pieces that are just commented out. They should be either uncommented or removed.
except Exception as e: | ||
logger.error(str(e), exc_info=True) | ||
user_profile = UserProfile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some dummy values for the super user to fix it.
common/views.py
Outdated
@@ -170,72 +169,48 @@ def get_user_profile_info(self, request): | |||
|
|||
def get(self, request, *args, **kwargs): | |||
user_profile_data = self.get_user_profile_info(request) | |||
common_user = True if not request.user.is_superuser else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common_user = True if not request.user.is_superuser else False | |
common_user = not request.user.is_superuser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And superuser can be a regular promoted user, so this would be misleading.
What I suggest us doing is keeping it a broken page for now, but add a jira issue to populate default super user with this data. We should bring it to the broad group.
common/views.py
Outdated
# For the superuser it is expected to not to be able to update records | ||
# as it does not have a user profile object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm talking about as well, may be we should actually generate this data for the super user as well. Let's discuss this with the team.
You can merge the code:) |
Thanks a lot. I have done it. |
Description
Reference: SS-643
It should be an option under the Profile dropdown. Users can update their first name, last name, and department. The university and email will be shown but can't be edited. There should be a note on the page saying that to change email or university affiliation, they need to contact [email protected].
Types of changes
new feature
Checklist
If you're unsure about any of the items below, don't hesitate to ask. We're here to help!
This is simply a reminder of what we are going to look for before merging your code.
Further comments
Anything else you think we should know before merging your code!