-
Notifications
You must be signed in to change notification settings - Fork 349
Closes #1451 Added user categories to profile and settings #1459
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,83 +10,83 @@ | |
|
|
||
| {% block content %} | ||
| <section style='display: flex;justify-content: center; padding-top: 20px;'> | ||
| <div class="setting card" style="width: 75%;"> | ||
| <div class="card-content"> | ||
| <div class="step-title"> | ||
| <div class="section"> | ||
| <div class="title-lato center"> | ||
| Account Settings | ||
| </div> | ||
| </div> | ||
| <div class="accent-line"></div> | ||
| {{form.non_field_errors}} | ||
| <form method="POST" enctype="multipart/form-data"> | ||
| {% csrf_token %} | ||
| <div class='row'> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.first_name.errors}}</span> | ||
| {{form.first_name.label_tag}} | ||
| {{form.first_name}} | ||
| </div> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.last_name.errors}}</span> | ||
| {{form.last_name.label_tag}} | ||
| {{form.last_name}} | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.profile_image.errors}}</span> | ||
| {{form.profile_image.label_tag}} | ||
| {{form.profile_image}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.username.errors}}</span> | ||
| {{form.username.label_tag}} | ||
| {{form.username}} | ||
| </div> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.email.errors}}</span> | ||
| {{form.email.label_tag}} | ||
| {{form.email}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class="col s24 m12"> | ||
| <span> {{form.about_me.errors}}</span> | ||
| {{form.about_me.label_tag}} | ||
| {{form.about_me}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class="col s24 m12"> | ||
| <span> {{form.categories.errors}}</span> | ||
| {{form.categories.label_tag}} | ||
| {{form.categories}} | ||
| </div> | ||
| </div> | ||
| <div class="row center"> | ||
| {%if not readonly %} | ||
| <button class='btn' type='submit' value="Save Changes">Save Changes</button> | ||
| {% endif%} | ||
| </div> | ||
| </form> | ||
| <div class="row center"> | ||
| <button id="delete-account-button" style="background-color: #ee6e73" class="cd-popup-trigger btn">Expunge Account</button> | ||
| </div> | ||
| <div class="setting card" style="width: 75%;"> | ||
| <div class="card-content"> | ||
| <div class="step-title"> | ||
| <div class="section"> | ||
| <div class="title-lato center"> | ||
| Account Settings | ||
| </div> | ||
| </div> | ||
| <div class="accent-line"></div> | ||
| {{form.non_field_errors}} | ||
| <form method="POST" enctype="multipart/form-data"> | ||
| {% csrf_token %} | ||
| <div class='row'> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.first_name.errors}}</span> | ||
| {{form.first_name.label_tag}} | ||
| {{form.first_name}} | ||
| </div> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.last_name.errors}}</span> | ||
| {{form.last_name.label_tag}} | ||
| {{form.last_name}} | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.profile_image.errors}}</span> | ||
| {{form.profile_image.label_tag}} | ||
| {{form.profile_image}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.username.errors}}</span> | ||
| {{form.username.label_tag}} | ||
| {{form.username}} | ||
| </div> | ||
| <div class=" col s12 m6 "> | ||
| <span class='error'>{{form.email.errors}}</span> | ||
| {{form.email.label_tag}} | ||
| {{form.email}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class="col s24 m12"> | ||
| <span> {{form.about_me.errors}}</span> | ||
| {{form.about_me.label_tag}} | ||
| {{form.about_me}} | ||
| </div> | ||
| </div> | ||
| <div class='row'> | ||
| <div class="col s12 m6"> | ||
| {{form.categories.errors}} | ||
| {{form.categories.label_tag}} | ||
| {{form.categories}} | ||
|
Comment on lines
+64
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks correct. I'm not sure why the field isn't rendering. One thing to try would be to post this code and the form definition to a Stack Overflow question to get help from the broader community.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright I'll do just that. but, I think it's a UI issue, I made an observation as to this form section missing out this tag could that be the issue?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only UI here is whatever we write. Since we are using a Django Form to render UI fields, we need to figure out the correct way to render a ModelMultiSelect form field. Hence, asking on StackOverflow to see if what we are trying is correct.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks @brylie, I've asked on stackoverflow hoping to get answer soon.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that might help in this case would be to create an empty testing project to work directly with the form fields. Just create a new Django project with a single app. Define two models in the app with one ForeignKey field. Create a form/template/view and see if the form field renders correctly. That will isolate the problem to give us an idea of how it should work.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great thoughts @brylie. I'll do just that right away. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I pick this up, if this issue has not been resolved?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing. You may need to start a fresh branch, since this one has conflicts. |
||
| </div> | ||
| </div> | ||
| <div class="row center"> | ||
| {% if not readonly %} | ||
| <button class='btn' type='submit' value="Save Changes">Save Changes</button> | ||
| {% endif %} | ||
| </div> | ||
| </form> | ||
| <div class="row center"> | ||
| <button id="delete-account-button" style="background-color: #ee6e73" class="cd-popup-trigger btn">Expunge Account</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| {% endblock content %} | ||
|
|
||
| {% block extra_js %} | ||
| <script type="text/javascript"> | ||
| document.addEventListener('DOMContentLoaded', function(event) { | ||
| const button = document.getElementById('delete-account-button'); | ||
|
|
||
| button.addEventListener('click', (event) => { | ||
| // Confirm user intent before committing to expunge | ||
| if (window.confirm('Are you certain you want to expunge your information? This action is irreversible.')) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,7 @@ def get_initial(self): | |
| "last_name": profile.last_name or None, | ||
| "about_me": profile.about_me or None, | ||
| "profile_image": profile.profile_image or None, | ||
| "categories": profile.categories.add() or None, | ||
| } | ||
| ) | ||
| return super(SettingsView, self).get_initial() | ||
|
|
@@ -178,12 +179,14 @@ class UserProfileView(LoginRequiredMixin, View): | |
|
|
||
| def get(self, request, username=None): | ||
| profile = get_object_or_404(Profile, user__username=username) | ||
| # categories = profile.categories.all() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this commented out code. |
||
|
|
||
| return TemplateResponse( | ||
| request, | ||
| "account.html", | ||
| { | ||
| "profile": profile, | ||
| # "categories": categories, | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.