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

SS-643 Users can edit their account details #235

Merged
merged 30 commits into from
Oct 22, 2024

Conversation

anondo1969
Copy link
Contributor

@anondo1969 anondo1969 commented Oct 7, 2024

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.

  • This pull request is against develop branch (not applicable for hotfixes)
  • I have included a link to the issue on GitHub or JIRA (if any)
  • I have included migration files (if there are changes to the model classes)
  • I have included, reviewed and executed tests (unit and end2end) to complement my changes
  • I have updated the related documentation (if necessary)
  • I have added a reviewer for this pull request
  • I have added myself as an author for this pull request
  • In the case I have modified settings.py, then I have also updated the studio-settings-configmap.yaml file in serve-charts

Further comments

Anything else you think we should know before merging your code!

@anondo1969 anondo1969 self-assigned this Oct 7, 2024
common/views.py Outdated Show resolved Hide resolved
templates/user/profile.html Outdated Show resolved Hide resolved
templates/user/profile.html Outdated Show resolved Hide resolved
templates/registration/edit_profile.html Outdated Show resolved Hide resolved
templates/registration/edit_profile.html Outdated Show resolved Hide resolved
common/views.py Outdated Show resolved Hide resolved
common/views.py Outdated Show resolved Hide resolved
common/views.py Outdated Show resolved Hide resolved
@anondo1969 anondo1969 marked this pull request as ready for review October 14, 2024 10:46
common/views.py Outdated Show resolved Hide resolved
common/forms.py Outdated Show resolved Hide resolved
common/forms.py Outdated Show resolved Hide resolved
Comment on lines +189 to +203
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,
},
)
Copy link
Contributor

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.

Copy link
Contributor Author

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'.

common/forms.py Outdated Show resolved Hide resolved
anondo1969 and others added 6 commits October 15, 2024 13:03
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"),
Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Contributor Author

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 Show resolved Hide resolved
common/views.py Outdated
Comment on lines 218 to 219
user_form_retrived_data.password1 = user_profile_data.user.password
user_form_retrived_data.password2 = user_profile_data.user.password
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@churnikov churnikov left a 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.

common/urls.py Outdated Show resolved Hide resolved
common/urls.py Outdated Show resolved Hide resolved
common/views.py Outdated Show resolved Hide resolved
Comment on lines +165 to +167
except Exception as e:
logger.error(str(e), exc_info=True)
user_profile = UserProfile()
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, just want to tell you that it doesn't solve it for the admin user.
image

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
common_user = True if not request.user.is_superuser else False
common_user = not request.user.is_superuser

Copy link
Contributor

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
Comment on lines 222 to 223
# For the superuser it is expected to not to be able to update records
# as it does not have a user profile object.
Copy link
Contributor

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.

@churnikov
Copy link
Contributor

You can merge the code:)
But please do the squash and merge and write details of what was done in the resulting commit

@anondo1969 anondo1969 merged commit 0ed3393 into develop Oct 22, 2024
2 checks passed
@anondo1969 anondo1969 deleted the SS-643-Make-an-option-to-edit-account-details branch October 22, 2024 13:44
@anondo1969
Copy link
Contributor Author

You can merge the code:) But please do the squash and merge and write details of what was done in the resulting commit

Thanks a lot. I have done it.

@akochari akochari changed the title Ss 643 make an option to edit account details SS-643 Users can edit their account details Nov 5, 2024
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.

4 participants