-
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
Merged
anondo1969
merged 30 commits into
develop
from
SS-643-Make-an-option-to-edit-account-details
Oct 22, 2024
Merged
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d321a3f
Updated info about using Serve for teaching (#194)
akochari 2b5cadc
Revert "Updated info about using Serve for teaching (#194)"
akochari 2d769be
Merge branch 'staging' into main
sandstromviktor ab7d54f
Merge branch 'staging'
churnikov 46f589c
Merge branch 'staging'
churnikov c958069
SS-643-Make-an-option-to-edit-account-details
anondo1969 7c8099b
SS-643-Make-an-option-to-edit-account-details
anondo1969 4e3de76
SS-643 extending ProfileForm
anondo1969 d38f4ce
SS-643 Updated edit HTML form
anondo1969 d86a443
SS-643 Updated edit HTML form
anondo1969 32b49eb
SS-643 pre-commit check fixed
anondo1969 bba6f8b
SS-643 pre-commit with black check
anondo1969 0048d66
SS-643 pre-commit with black check 2
anondo1969 cf33450
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 cded668
fix failing e2e test
akochari 8194013
change the edit profile icon
akochari a05bf15
uncomment the line I accidentally commented out
akochari ee23c4e
Update common/views.py
anondo1969 b3481fd
Update common/forms.py
anondo1969 6bb12aa
Update common/forms.py
anondo1969 41b2862
fix super class init.
anondo1969 491b6f8
changes in view
anondo1969 da00974
ensure login required in form post method
anondo1969 f78edf6
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 7f13f1e
ensuring curl injection does not work
anondo1969 a96fdfd
fixing the profile-edit bug in superuser mode
anondo1969 5a7fa52
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 0d50532
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 2d11a65
differentiate admin user and common user with or without Staff/Superu…
anondo1969 ce5e4a8
differentiate admin user and common user with or without Staff/Superu…
anondo1969 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,7 @@ class UserForm(BootstrapErrorFormMixin, UserCreationForm): | |
"Swedish university</a> email address. If you are not affiliated with a Swedish university, " | ||
"your account request will be reviewed manually." | ||
), | ||
#disabled = True, | ||
) | ||
password1 = forms.CharField( | ||
min_length=8, | ||
|
@@ -321,3 +322,85 @@ class Meta: | |
fields = [ | ||
"token", | ||
] | ||
|
||
|
||
class UserEditForm(BootstrapErrorFormMixin, forms.ModelForm): | ||
first_name = forms.CharField( | ||
min_length=1, | ||
max_length=30, | ||
label="First name", | ||
widget=forms.TextInput(attrs={"class": "form-control"}), | ||
|
||
) | ||
last_name = forms.CharField( | ||
min_length=1, | ||
max_length=30, | ||
label="Last name", | ||
widget=forms.TextInput(attrs={"class": "form-control"}), | ||
) | ||
email = forms.EmailField( | ||
max_length=254, | ||
label="Email", | ||
widget=forms.TextInput(attrs={"class": "form-control"}), | ||
help_text=mark_safe( | ||
"Email address can not be changed. Please email [email protected] with any questions." | ||
), | ||
disabled = True, | ||
) | ||
|
||
|
||
required_css_class = "required" | ||
|
||
class Meta: | ||
model = User | ||
fields = [ | ||
"username", | ||
"first_name", | ||
"last_name", | ||
"email", | ||
"password1", | ||
"password2", | ||
] | ||
exclude = [ | ||
"username", | ||
"password1", | ||
"password2", | ||
] | ||
|
||
def __repr__(self) -> str: | ||
return f"{self.__class__.__name__}({self.data})" | ||
|
||
|
||
class ProfileEditForm(BootstrapErrorFormMixin, forms.ModelForm): | ||
affiliation = forms.ChoiceField( | ||
widget=forms.Select(attrs={"class": "form-control"}), | ||
label="University", | ||
choices=UNIVERSITIES, | ||
help_text="Affiliation can not be changed. Please email [email protected] with any questions.", | ||
disabled = True, | ||
) | ||
department = forms.CharField( | ||
widget=ListTextWidget(data_list=DEPARTMENTS, name="department-list", attrs={"class": "form-control"}), | ||
label="Department", | ||
required=False, | ||
help_text="Select closest department name or enter your own.", | ||
) | ||
|
||
required_css_class = "required" | ||
|
||
class Meta: | ||
model = UserProfile | ||
fields = [ | ||
"affiliation", | ||
"department", | ||
"note", | ||
"why_account_needed", | ||
] | ||
exclude = [ | ||
"note", | ||
"why_account_needed", | ||
] | ||
|
||
def __repr__(self): | ||
return f"{self.__class__.__name__}({self.data})" | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{% extends 'base.html' %} | ||
anondo1969 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{% block title %}Edit your Profile{% endblock %} | ||
|
||
{% load static %} | ||
{% load is_login_signup_disabled %} | ||
{% block extra_scripts %} | ||
<script src="{% static 'js/form-helpers.js' %}"></script> | ||
{% endblock %} | ||
|
||
|
||
{% block content %} | ||
<div class="container"> | ||
{% if not maintenance_mode|is_login_signup_disabled %} | ||
<div class="card border-0 shadow-lg my-5"> | ||
<div class="card-body p-0"> | ||
<!-- Nested Row within Card Body --> | ||
<div class="row"> | ||
<div class="col-xs-12 col-lg-8 offset-lg-2"> | ||
<div class="px-3 py-5"> | ||
<div class="row"> | ||
<div class="col"> | ||
<div class="col"> | ||
<h2 class="text-dark mb-4 text-center">Edit your Profile</h2> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="mw-30 m-auto pt-1"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="row pb-3"> | ||
<div class="col-12"> | ||
<label class="form-label">{{form.email.label_tag}}</label> | ||
{{form.email}} | ||
<div class="form-text">{{form.email.help_text}}</div> | ||
{% if form.email.errors %} | ||
<div id="validation_email" class="invalid-feedback pt-1"> | ||
anondo1969 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{% for error in form.email.errors %} | ||
<p class="m-0">{{error|escape}}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="row pb-3"> | ||
<div class="col-12 col-md-6 pb-3 pb-md-0"> | ||
<label class="form-label">{{form.first_name.label_tag}}</label> | ||
{{form.first_name}} | ||
{% if form.first_name.errors %} | ||
<div class="form-text">{{form.first_name.help_text}}</div> | ||
<div id="validation_first_name" class="invalid-feedback pt-1"> | ||
{% for error in form.first_name.errors %} | ||
<p class="m-0">{{error|escape}}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="col-12 col-md-6 pb-3 pb-md-0"> | ||
<label class="form-label">{{form.last_name.label_tag}} </label> | ||
{{form.last_name}} | ||
<div class="form-text">{{form.last_name.help_text}}</div> | ||
{% if form.last_name.errors %} | ||
<div id="validation_last_name" class="pt-1 invalid-feedback"> | ||
{% for error in form.last_name.errors %} | ||
<p class="m-0">{{error|escape}}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
<div class="row pb-3"> | ||
<div class="col-12 col-md-6 pb-3 pb-md-0"> | ||
<label class="form-label">{{profile_form.affiliation.label_tag}}</label> | ||
{{ profile_form.affiliation }} | ||
<div class="form-text">{{profile_form.affiliation.help_text}}</div> | ||
{% if profile_form.affiliation.errors %} | ||
<div id="validation_affiliation" class="pt-1 invalid-feedback"> | ||
{% for error in profile_form.affiliation.errors %} | ||
<p class="m-0">{{error|escape}}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="col-12 col-md-6 pb-3 pb-md-0"> | ||
<label class="form-label">{{profile_form.department.label_tag}}</label> | ||
{{ profile_form.department | safe }} | ||
<div class="form-text">{{profile_form.department.help_text}}</div> | ||
{% if profile_form.department.errors %} | ||
<div id="validation_department" class="pt-1 invalid-feedback"> | ||
{% for error in profile_form.department.errors %} | ||
<p class="m-0">{{error|escape}}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="d-flex justify-content-end"> | ||
|
||
<a href="/" class="btn me-2">Cancel</a> | ||
<input type="submit" name="save" value="Submit" class="btn btn-primary ms-2" | ||
id="submit-id-save"> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<hr> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}Change profile{% endblock %} | ||
|
||
{% block content %} | ||
<!-- Begin Page Content --> | ||
<div class="container"> | ||
<!-- Main Content Here --> | ||
<div class="card o-hidden border-0 shadow-lg my-5"> | ||
<div class="card-body p-0"> | ||
<div class="row"> | ||
<div class="col-lg-3"></div> | ||
<div class="col-lg-6"> | ||
<div class="p-5"> | ||
<div class="text-center"> | ||
<h1 class="h4 text-gray-900 mb-4">Profile editedd</h1> | ||
</div> | ||
<div class="text-center"> | ||
<p>Your profile has been edited successfully!</p> | ||
<a class="btn btn-primary" href="{% url 'projects:index' %}">Go to dashboard</a> | ||
<hr > | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains 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
Oops, something went wrong.
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.
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.
Btw, just want to tell you that it doesn't solve it for the admin user.
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.