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): ...@@ -18,6 +18,12 @@ class NicknameForm(forms.ModelForm):
fields = ['nickname'] fields = ['nickname']
class BioForm(forms.ModelForm):
class Meta:
model = User
fields = ['bio']
class KeyForm(forms.ModelForm): class KeyForm(forms.ModelForm):
class Meta: class Meta:
model = Key model = Key
......
...@@ -16,4 +16,5 @@ urlpatterns = [ ...@@ -16,4 +16,5 @@ urlpatterns = [
path('edit_itemT/<int:pk>', views.ShowEditItemT, name='edit_itemT'), path('edit_itemT/<int:pk>', views.ShowEditItemT, name='edit_itemT'),
path('delete_itemT/<int:pk>', views.ShowDeleteItemT, name='delete_itemT'), path('delete_itemT/<int:pk>', views.ShowDeleteItemT, name='delete_itemT'),
path('edit_nickname', views.ShowEditNickname, name='edit_nickname'), path('edit_nickname', views.ShowEditNickname, name='edit_nickname'),
path('edit_bio', views.ShowEditBio, name='edit_bio'),
] ]
...@@ -5,6 +5,7 @@ from .forms import ( ...@@ -5,6 +5,7 @@ from .forms import (
HomeForm, HomeForm,
UserForm, UserForm,
NicknameForm, NicknameForm,
BioForm,
KeyForm, KeyForm,
ItemsThisWeekForm, ItemsThisWeekForm,
ItemsTodayForm, ItemsTodayForm,
...@@ -63,6 +64,19 @@ def ShowEditNickname(request): ...@@ -63,6 +64,19 @@ def ShowEditNickname(request):
return render(request, 'edit_nickname.html', {'form': form}) 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): def ShowKey(request):
key_list = Key.objects.all() key_list = Key.objects.all()
return render(request, 'key.html', {'key_list': key_list}) return render(request, 'key.html', {'key_list': key_list})
......
...@@ -42,7 +42,7 @@ a { ...@@ -42,7 +42,7 @@ a {
font-size: 1.5em; font-size: 1.5em;
} }
#key, #this_week, #today, #delete { #center {
margin: 0 auto; margin: 0 auto;
width: 50%; width: 50%;
font-size: 1.5em; font-size: 1.5em;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% block content %} {% block content %}
<div id='today'> <div id='center'>
<h3> Are you sure you want to delete this item? </h3> <h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'> <form action='' method='POST'>
{% csrf_token %} {% csrf_token %}
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% block content %} {% block content %}
<div id='this_week'> <div id='center'>
<h3> Are you sure you want to delete this item? </h3> <h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'> <form action='' method='POST'>
{% csrf_token %} {% 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 @@ ...@@ -7,10 +7,12 @@
{% block content %} {% block content %}
<form action='' method='POST'> <div id='center'>
<form action='' method='POST'>
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<input type='submit' name='Submit' value='Save'> <input type='submit' name='Submit' value='Save'>
</form> </form>
</div>
{% endblock %} {% endblock %}
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
{% block content %} {% block content %}
<form action='' method='POST'> <div id='center'>
<form action='' method='POST'>
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<input type='submit' name='Submit' value='Save'> <input type='submit' name='Submit' value='Save'>
</form> </form>
</div>
{% endblock %} {% endblock %}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% block content %} {% block content %}
<div id='key'> <div id='center'>
<h3>Your Keys</h3> <h3>Your Keys</h3>
<br> <br>
{% for key in key_list %} {% for key in key_list %}
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
<a href='{% url 'edit_nickname' %}'><button type='button'>Edit</button></a> <a href='{% url 'edit_nickname' %}'><button type='button'>Edit</button></a>
</p> </p>
<br> <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>
<div id='image-container'> <div id='image-container'>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% block content %} {% block content %}
<div id='this_week'> <div id='center'>
<h2>04.12.MON - 04.18.SUN</h2> <h2>04.12.MON - 04.18.SUN</h2>
<br> <br>
{% for item in item_list %} {% for item in item_list %}
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% block content %} {% block content %}
<div id='today'> <div id='center'>
<h2>04.14.WED</h2> <h2>04.14.WED</h2>
<br> <br>
{% for item in item_list %} {% 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