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

Added ItemsThisWeek form to "add_itemTW" template

parent ab53dd6d
from django import forms from django import forms
from .models import Key from .models import Key, ItemsThisWeek
class HomeForm(forms.Form): class HomeForm(forms.Form):
...@@ -10,3 +10,9 @@ class KeyForm(forms.ModelForm): ...@@ -10,3 +10,9 @@ class KeyForm(forms.ModelForm):
class Meta: class Meta:
model = Key model = Key
fields = '__all__' fields = '__all__'
class ItemsThisWeekForm(forms.ModelForm):
class Meta:
model = ItemsThisWeek
fields = '__all__'
...@@ -8,5 +8,6 @@ urlpatterns = [ ...@@ -8,5 +8,6 @@ urlpatterns = [
path('key/', views.ShowKey, name='key'), path('key/', views.ShowKey, name='key'),
path('add_key/', views.ShowAddKey, name='add_key'), path('add_key/', views.ShowAddKey, name='add_key'),
path('this_week/', views.ShowThisWeek, name='this_week'), path('this_week/', views.ShowThisWeek, name='this_week'),
path('add_itemTW/', views.ShowAddItemTW, name='add_itemTW'),
path('today/', views.ShowToday, name='today'), path('today/', views.ShowToday, name='today'),
] ]
import datetime import datetime
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.http import HttpResponse from django.http import HttpResponse
from .forms import HomeForm, KeyForm from .forms import HomeForm, KeyForm, ItemsThisWeekForm
from .models import Key from .models import Key
...@@ -32,7 +32,6 @@ def ShowKey(request): ...@@ -32,7 +32,6 @@ def ShowKey(request):
def ShowAddKey(request): def ShowAddKey(request):
form = KeyForm() form = KeyForm()
if request.method == 'POST': if request.method == 'POST':
form = KeyForm(request.POST) form = KeyForm(request.POST)
if form.is_valid(): if form.is_valid():
...@@ -46,6 +45,18 @@ def ShowThisWeek(request): ...@@ -46,6 +45,18 @@ def ShowThisWeek(request):
return render(request, 'this_week.html') return render(request, 'this_week.html')
def ShowAddItemTW(request):
form = ItemsThisWeekForm()
if request.method == 'POST':
form = ItemsThisWeekForm(request.POST)
if form.is_valid():
form.save()
return redirect('this_week')
return render(request, 'add_itemTW.html', {'form': form})
def ShowToday(request): def ShowToday(request):
my_date = datetime.datetime.now() my_date = datetime.datetime.now()
return render(request, 'today.html', {'my_date': my_date}) return render(request, 'today.html', {'my_date': my_date})
{% 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='Add'>
</form>
{% endblock %}
...@@ -8,15 +8,9 @@ ...@@ -8,15 +8,9 @@
{% block content %} {% block content %}
<div id='this_week'> <div id='this_week'>
<h2>03.15.MON - 03.21.SUN</h2> <h2>04.12.MON - 04.18.SUN</h2>
<br>
<p>• 7AM water plants</p> <a href='{% url 'add_itemTW' %}'><button type='button'> Add Item </button></a>
<p>• 8AM walk the dogs</p>
<p>- don't cram</p>
<p>○ 18 2:30PM Personal Counseling with Sir Marvin</p>
<p>○ 20 1PM DSC org meeting</p>
<p>- never hit up a random person on twitter ever again</p>
<p>○ 21 9AM ACOMM org meeting</p>
</div> </div>
{% endblock %} {% endblock %}
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