Commit 9fcf6e04 authored by James Esguerra's avatar James Esguerra

Added edit button for bio

parent 51e5837d
......@@ -18,6 +18,12 @@ class NicknameForm(forms.ModelForm):
fields = ['nickname']
class BioForm(forms.ModelForm):
class Meta:
model = User
fields = ['bio']
class KeyForm(forms.ModelForm):
class Meta:
model = Key
......
......@@ -16,4 +16,5 @@ urlpatterns = [
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'),
path('edit_bio', views.ShowEditBio, name='edit_bio'),
]
......@@ -5,6 +5,7 @@ from .forms import (
HomeForm,
UserForm,
NicknameForm,
BioForm,
KeyForm,
ItemsThisWeekForm,
ItemsTodayForm,
......@@ -63,6 +64,19 @@ def ShowEditNickname(request):
return render(request, 'edit_nickname.html', {'form': form})
def ShowEditBio(request):
user = User.objects.get(pk=1)
form = BioForm(instance=user)
if request.method == 'POST':
form = BioForm(request.POST, instance=user)
if form.is_valid():
form.save()
return redirect('profile')
return render(request, 'edit_bio.html', {'form': form})
def ShowKey(request):
key_list = Key.objects.all()
return render(request, 'key.html', {'key_list': key_list})
......
......@@ -42,7 +42,7 @@ a {
font-size: 1.5em;
}
#key, #this_week, #today, #delete {
#center {
margin: 0 auto;
width: 50%;
font-size: 1.5em;
......
......@@ -7,7 +7,7 @@
{% block content %}
<div id='today'>
<div id='center'>
<h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'>
{% csrf_token %}
......
......@@ -7,7 +7,7 @@
{% block content %}
<div id='this_week'>
<div id='center'>
<h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'>
{% csrf_token %}
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Key {% endblock %}
{% block header %} Key {% endblock %}
{% block content %}
<div id='center'>
<form action='' method='POST'>
{% csrf_token %}
{{ form }}
<input type='submit' name='Submit' value='Save'>
</form>
</div>
{% endblock %}
......@@ -7,10 +7,12 @@
{% block content %}
<form action='' method='POST'>
<div id='center'>
<form action='' method='POST'>
{% csrf_token %}
{{ form }}
<input type='submit' name='Submit' value='Save'>
</form>
</form>
</div>
{% endblock %}
......@@ -7,10 +7,12 @@
{% block content %}
<form action='' method='POST'>
<div id='center'>
<form action='' method='POST'>
{% csrf_token %}
{{ form }}
<input type='submit' name='Submit' value='Save'>
</form>
</form>
</div>
{% endblock %}
......@@ -7,7 +7,7 @@
{% block content %}
<div id='key'>
<div id='center'>
<h3>Your Keys</h3>
<br>
{% for key in key_list %}
......
......@@ -15,7 +15,11 @@
<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 }}
<a href='{% url 'edit_bio' %}'><button type='button'>Edit</button></a>
</p>
</div>
<div id='image-container'>
......
......@@ -7,7 +7,7 @@
{% block content %}
<div id='this_week'>
<div id='center'>
<h2>04.12.MON - 04.18.SUN</h2>
<br>
{% for item in item_list %}
......
......@@ -7,7 +7,7 @@
{% block content %}
<div id='today'>
<div id='center'>
<h2>04.14.WED</h2>
<br>
{% for item in item_list %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment