Commit 61f8a525 authored by James Esguerra's avatar James Esguerra

Added "Mark as done" button to this week view

parent 9fcf6e04
...@@ -34,9 +34,11 @@ class ItemsThisWeekForm(forms.ModelForm): ...@@ -34,9 +34,11 @@ class ItemsThisWeekForm(forms.ModelForm):
class Meta: class Meta:
model = ItemsThisWeek model = ItemsThisWeek
fields = '__all__' fields = '__all__'
exclude = ('is_task',)
class ItemsTodayForm(forms.ModelForm): class ItemsTodayForm(forms.ModelForm):
class Meta: class Meta:
model = ItemsToday model = ItemsToday
fields = '__all__' fields = '__all__'
exclude = ('is_task',)
# Generated by Django 3.1.7 on 2021-04-07 12:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pages', '0010_auto_20210407_1702'),
]
operations = [
migrations.AddField(
model_name='itemsthisweek',
name='is_task',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='itemstoday',
name='is_task',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='user',
name='bio',
field=models.TextField(max_length=100),
),
migrations.AlterField(
model_name='user',
name='nickname',
field=models.CharField(max_length=50),
),
]
# Generated by Django 3.1.7 on 2021-04-07 12:57
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('pages', '0011_auto_20210407_2046'),
]
operations = [
migrations.RemoveField(
model_name='itemsthisweek',
name='is_task',
),
migrations.RemoveField(
model_name='itemstoday',
name='is_task',
),
]
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 ( from .forms import (
...@@ -94,7 +93,17 @@ def ShowAddKey(request): ...@@ -94,7 +93,17 @@ def ShowAddKey(request):
def ShowThisWeek(request): def ShowThisWeek(request):
item_list = ItemsThisWeek.objects.all() item_list = list(ItemsThisWeek.objects.all())
if request.method == 'POST':
for i in request.POST.keys():
name = i
for item in item_list:
if str(item.id) == name:
item.key_type.key_name = 'Task done'
break
return render(request, 'this_week.html', {'item_list': item_list}) return render(request, 'this_week.html', {'item_list': item_list})
...@@ -132,7 +141,7 @@ def ShowDeleteItemTW(request, pk): ...@@ -132,7 +141,7 @@ def ShowDeleteItemTW(request, pk):
def ShowToday(request): def ShowToday(request):
item_list = ItemsToday.objects.all() item_list = list(ItemsToday.objects.all())
return render(request, 'today.html', {'item_list': item_list}) return render(request, 'today.html', {'item_list': item_list})
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
<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 %}
<p> <form method='POST'>
<b>{{ item.key_type }}:</b> {{ item.details }} <b>{{ item.key_type }}:</b> {{ item.details }}
<a href='{% url 'edit_itemTW' item.pk %}'><button type='button'> Edit </button></a> <a href='{% url 'edit_itemTW' item.pk %}'><button type='button'> Edit </button></a>
<a href='{% url 'delete_itemTW' item.pk %}'><button type='button'> Delete </button></a> <a href='{% url 'delete_itemTW' item.pk %}'><button type='button'> Delete </button></a>
</p> {% if item.key_type.key_name == 'Task' %}
{% csrf_token %}
<input type='submit' name='{{ item.id }}' value='Mark as done'/>
{% endif %}
</form>
{% endfor %} {% endfor %}
<a href='{% url 'add_itemTW' %}'><button type='button'> Add Item </button></a> <a href='{% url 'add_itemTW' %}'><button type='button'> Add Item </button></a>
</div> </div>
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<b>{{ item.key_type }}:</b> {{ item.details }} <b>{{ item.key_type }}:</b> {{ item.details }}
<a href='{% url 'edit_itemT' item.pk %}'><button type='button'> Edit </button></a> <a href='{% url 'edit_itemT' item.pk %}'><button type='button'> Edit </button></a>
<a href='{% url 'delete_itemT' item.pk %}'><button type='button'> Delete </button></a> <a href='{% url 'delete_itemT' item.pk %}'><button type='button'> Delete </button></a>
{% if item.key_type.key_name == 'Task' %}
<input type='submit' name='Submit' method='POST' value='Mark as done'>
{% endif %}
<p> <p>
{% endfor %} {% endfor %}
<a href='{% url 'add_itemT' %}'><button type='button'> Add Item </button></a> <a href='{% url 'add_itemT' %}'><button type='button'> Add Item </button></a>
......
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