Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
esguerra_lab1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
James Esguerra
esguerra_lab1
Commits
51e5837d
Commit
51e5837d
authored
Apr 07, 2021
by
James Esguerra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added edit button for nickname
parent
d291048e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
5 deletions
+44
-5
forms.cpython-38.pyc
pages/__pycache__/forms.cpython-38.pyc
+0
-0
urls.cpython-38.pyc
pages/__pycache__/urls.cpython-38.pyc
+0
-0
views.cpython-38.pyc
pages/__pycache__/views.cpython-38.pyc
+0
-0
forms.py
pages/forms.py
+7
-3
urls.py
pages/urls.py
+1
-0
views.py
pages/views.py
+14
-0
edit_nickname.html
templates/edit_nickname.html
+16
-0
profile.html
templates/profile.html
+6
-2
No files found.
pages/__pycache__/forms.cpython-38.pyc
View file @
51e5837d
No preview for this file type
pages/__pycache__/urls.cpython-38.pyc
View file @
51e5837d
No preview for this file type
pages/__pycache__/views.cpython-38.pyc
View file @
51e5837d
No preview for this file type
pages/forms.py
View file @
51e5837d
...
...
@@ -10,9 +10,13 @@ class UserForm(forms.ModelForm):
class
Meta
:
model
=
User
fields
=
[
'profile_photo'
]
label
=
{
'profile_photo'
:
''
,
}
class
NicknameForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
'nickname'
]
class
KeyForm
(
forms
.
ModelForm
):
class
Meta
:
...
...
pages/urls.py
View file @
51e5837d
...
...
@@ -15,4 +15,5 @@ urlpatterns = [
path
(
'add_itemT'
,
views
.
ShowAddItemT
,
name
=
'add_itemT'
),
path
(
'edit_itemT/<int:pk>'
,
views
.
ShowEditItemT
,
name
=
'edit_itemT'
),
path
(
'delete_itemT/<int:pk>'
,
views
.
ShowDeleteItemT
,
name
=
'delete_itemT'
),
path
(
'edit_nickname'
,
views
.
ShowEditNickname
,
name
=
'edit_nickname'
),
]
pages/views.py
View file @
51e5837d
...
...
@@ -4,6 +4,7 @@ from django.http import HttpResponse
from
.forms
import
(
HomeForm
,
UserForm
,
NicknameForm
,
KeyForm
,
ItemsThisWeekForm
,
ItemsTodayForm
,
...
...
@@ -49,6 +50,19 @@ def ShowProfile(request):
return
render
(
request
,
'profile.html'
,
context
)
def
ShowEditNickname
(
request
):
user
=
User
.
objects
.
get
(
pk
=
1
)
form
=
NicknameForm
(
instance
=
user
)
if
request
.
method
==
'POST'
:
form
=
NicknameForm
(
request
.
POST
,
instance
=
user
)
if
form
.
is_valid
():
form
.
save
()
return
redirect
(
'profile'
)
return
render
(
request
,
'edit_nickname.html'
,
{
'form'
:
form
})
def
ShowKey
(
request
):
key_list
=
Key
.
objects
.
all
()
return
render
(
request
,
'key.html'
,
{
'key_list'
:
key_list
})
...
...
templates/edit_nickname.html
0 → 100644
View file @
51e5837d
{% extends 'base.html' %}
{% load static %}
{% block title %} Key {% endblock %}
{% block header %} Key {% endblock %}
{% block content %}
<form
action=
''
method=
'POST'
>
{% csrf_token %}
{{ form }}
<input
type=
'submit'
name=
'Submit'
value=
'Save'
>
</form>
{% endblock %}
templates/profile.html
View file @
51e5837d
...
...
@@ -9,9 +9,13 @@
<div
id=
'profile'
>
<div>
<p><b>
Nickname:
</b>
{{ user.nickname }}
</p>
<p>
<b>
Nickname:
</b>
{{ user.nickname }}
<a
href=
'{% url '
edit_nickname
'
%}'
><button
type=
'button'
>
Edit
</button></a>
</p>
<br>
<p><b>
Bio:
</b>
{{ user.bio }}
</p>
<p><b>
Bio:
</b>
{{ user.bio }}
</p>
</div>
<div
id=
'image-container'
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment