Commit 005385ee authored by nikkastra's avatar nikkastra

in the middle of thisweek.html

parent b82139f2
...@@ -23,3 +23,14 @@ class Keys(forms.ModelForm): ...@@ -23,3 +23,14 @@ class Keys(forms.ModelForm):
class Meta: class Meta:
model = Key model = Key
fields = ['key', 'description'] fields = ['key', 'description']
class Task(forms.ModelForm):
class Meta:
model = Tasks
fields = ['key', 'task']
class EditTask(forms.Form):
edittask = forms.CharField(label='', max_length=100, required=False)
\ No newline at end of file
# Generated by Django 3.1.7 on 2021-04-09 15:01
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('bulletjournal', '0004_auto_20210409_2002'),
]
operations = [
migrations.AlterField(
model_name='tasks',
name='key',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bulletjournal.key'),
),
]
...@@ -28,5 +28,8 @@ class Key(models.Model): ...@@ -28,5 +28,8 @@ class Key(models.Model):
class Tasks(models.Model): class Tasks(models.Model):
name = models.ForeignKey(Name, on_delete=models.CASCADE) name = models.ForeignKey(Name, on_delete=models.CASCADE)
key = models.CharField(max_length=2) key = models.ForeignKey(Key, on_delete=models.CASCADE)
task = models.CharField(max_length=100) task = models.CharField(max_length=100)
def __str__(self):
return '{}: {}'.format(self.key, self.task)
\ No newline at end of file
...@@ -9,6 +9,8 @@ from .models import * ...@@ -9,6 +9,8 @@ from .models import *
name_dict = {} name_dict = {}
#oh la la wow wow wee wa king in the castle king in the castle i have a chair i
#have a chair o go to this go to this hey king in the castle
class NameListView(ListView): class NameListView(ListView):
...@@ -107,7 +109,39 @@ def key(request): ...@@ -107,7 +109,39 @@ def key(request):
def thisweek(request): def thisweek(request):
return render(request, 'thisweek.html') this_dict = {}
new_task = ''
if request.method == 'POST':
form1 = Task(request.POST)
form2 = EditTask(request.POST)
if form1.is_valid() or form2.is_valid():
x = ''
for y in request.POST:
x = y
if x == 'task':
new_task = Tasks(name=Name.objects.get(name=name_dict['name']), key=form1.cleaned_data['key'], task=form1.cleaned_data['task'])
new_task.save()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
elif x == 'edittask':
new_task.task = request.POST['edittask']
new_task.save()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
else:
form1 = Task()
form2 = EditTask()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
def today(request): def today(request):
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}{{ Name.name }}{% endblock %} {% block title %}{{ name.name }}{% endblock %}
{% block content %} {% block content %}
<h1>{{ Name.name }}</h1> <h1>{{ object.name }}</h1>
<p>kung ano man to</p> <p>kung ano man to</p>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
{% for x in the_keys %} {% for x in the_keys %}
<li> <li>
{{x}} {{x}}
</li> </li>
{% endfor %} {% endfor %}
{% else %} {% else %}
......
...@@ -9,7 +9,38 @@ ...@@ -9,7 +9,38 @@
{% block content %} {% block content %}
<h1> This Week </h1> <h1> This Week </h1>
<p> 03.29.MON - 04.04.SUN </p> <p> 03.29.MON - 04.04.SUN </p>
<p> - relax, holy week ngayon </p> <ul>
<p> ● minecraft </p> {% if the_tasks %}
<p> - this is fake of course, go do your reqs </p> {% for x in the_tasks %}
{{forloop.counter}}
<li>
{{x}}
<button type='button' onclick='document.getElementById("edit").open="open"'>Edit</button>
<button type='button' onclick='document.getElementById("delete").open="open"'>Delete</button>
</li>
{% endfor %}
{% endif %}
</ul>
<button type='button' onclick='document.getElementById("add").open="open"'>Add Item</button>
<dialog id="add">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form1}}
<input type="Submit" value="Add Task">
</form>
</dialog>
<dialog id="edit">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form2}}
<input type="Submit" value="Update">
</form>
</dialog>
<dialog id="delete">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form}}
<input type="Submit" value="Add Task">
</form>
</dialog>
{% endblock %} {% endblock %}
\ No newline at end of file
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